Chris@2: , Sebastian Heuer , Sebastian Bergmann Chris@2: * Chris@2: * For the full copyright and license information, please view the LICENSE Chris@2: * file that was distributed with this source code. Chris@2: */ Chris@2: Chris@2: namespace PharIo\Manifest; Chris@2: Chris@2: use DOMElement; Chris@2: use DOMNodeList; Chris@2: Chris@2: abstract class ElementCollection implements \Iterator { Chris@2: /** Chris@2: * @var DOMNodeList Chris@2: */ Chris@2: private $nodeList; Chris@2: Chris@2: private $position; Chris@2: Chris@2: /** Chris@2: * ElementCollection constructor. Chris@2: * Chris@2: * @param DOMNodeList $nodeList Chris@2: */ Chris@2: public function __construct(DOMNodeList $nodeList) { Chris@2: $this->nodeList = $nodeList; Chris@2: $this->position = 0; Chris@2: } Chris@2: Chris@2: abstract public function current(); Chris@2: Chris@2: /** Chris@2: * @return DOMElement Chris@2: */ Chris@2: protected function getCurrentElement() { Chris@2: return $this->nodeList->item($this->position); Chris@2: } Chris@2: Chris@2: public function next() { Chris@2: $this->position++; Chris@2: } Chris@2: Chris@2: public function key() { Chris@2: return $this->position; Chris@2: } Chris@2: Chris@2: public function valid() { Chris@2: return $this->position < $this->nodeList->length; Chris@2: } Chris@2: Chris@2: public function rewind() { Chris@2: $this->position = 0; Chris@2: } Chris@2: }