class ElementCollection
@template-implements Iterator<int,DOMElement>
Hierarchy
- class \PharIo\Manifest\ElementCollection implements \Iterator
Expanded class hierarchy of ElementCollection
File
-
vendor/
phar-io/ manifest/ src/ xml/ ElementCollection.php, line 22
Namespace
PharIo\ManifestView source
abstract class ElementCollection implements Iterator {
/** @var DOMElement[] */
private $nodes = [];
/** @var int */
private $position;
public function __construct(DOMNodeList $nodeList) {
$this->position = 0;
$this->importNodes($nodeList);
}
public abstract function current();
public function next() : void {
$this->position++;
}
public function key() : int {
return $this->position;
}
public function valid() : bool {
return $this->position < count($this->nodes);
}
public function rewind() : void {
$this->position = 0;
}
protected function getCurrentElement() : DOMElement {
return $this->nodes[$this->position];
}
private function importNodes(DOMNodeList $nodeList) : void {
foreach ($nodeList as $node) {
if (!$node instanceof DOMElement) {
throw new ElementCollectionException(sprintf('\\DOMElement expected, got \\%s', get_class($node)));
}
$this->nodes[] = $node;
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
ElementCollection::$nodes | private | property | @var DOMElement[] | |
ElementCollection::$position | private | property | @var int | |
ElementCollection::current | abstract public | function | 3 | |
ElementCollection::getCurrentElement | protected | function | ||
ElementCollection::importNodes | private | function | ||
ElementCollection::key | public | function | ||
ElementCollection::next | public | function | ||
ElementCollection::rewind | public | function | ||
ElementCollection::valid | public | function | ||
ElementCollection::__construct | public | function |