annotate vendor/phar-io/manifest/src/xml/ElementCollection.php @ 2:5311817fb629

Theme updates
author Chris Cannam
date Tue, 10 Jul 2018 13:19:18 +0000
parents
children
rev   line source
Chris@2 1 <?php
Chris@2 2 /*
Chris@2 3 * This file is part of PharIo\Manifest.
Chris@2 4 *
Chris@2 5 * (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
Chris@2 6 *
Chris@2 7 * For the full copyright and license information, please view the LICENSE
Chris@2 8 * file that was distributed with this source code.
Chris@2 9 */
Chris@2 10
Chris@2 11 namespace PharIo\Manifest;
Chris@2 12
Chris@2 13 use DOMElement;
Chris@2 14 use DOMNodeList;
Chris@2 15
Chris@2 16 abstract class ElementCollection implements \Iterator {
Chris@2 17 /**
Chris@2 18 * @var DOMNodeList
Chris@2 19 */
Chris@2 20 private $nodeList;
Chris@2 21
Chris@2 22 private $position;
Chris@2 23
Chris@2 24 /**
Chris@2 25 * ElementCollection constructor.
Chris@2 26 *
Chris@2 27 * @param DOMNodeList $nodeList
Chris@2 28 */
Chris@2 29 public function __construct(DOMNodeList $nodeList) {
Chris@2 30 $this->nodeList = $nodeList;
Chris@2 31 $this->position = 0;
Chris@2 32 }
Chris@2 33
Chris@2 34 abstract public function current();
Chris@2 35
Chris@2 36 /**
Chris@2 37 * @return DOMElement
Chris@2 38 */
Chris@2 39 protected function getCurrentElement() {
Chris@2 40 return $this->nodeList->item($this->position);
Chris@2 41 }
Chris@2 42
Chris@2 43 public function next() {
Chris@2 44 $this->position++;
Chris@2 45 }
Chris@2 46
Chris@2 47 public function key() {
Chris@2 48 return $this->position;
Chris@2 49 }
Chris@2 50
Chris@2 51 public function valid() {
Chris@2 52 return $this->position < $this->nodeList->length;
Chris@2 53 }
Chris@2 54
Chris@2 55 public function rewind() {
Chris@2 56 $this->position = 0;
Chris@2 57 }
Chris@2 58 }