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