1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace PHPHtmlParser\Dom;
- use Countable;
- use ArrayIterator;
- use IteratorAggregate;
- /**
- * Dom node object which will allow users to use it as
- * an array.
- */
- abstract class ArrayNode extends AbstractNode implements IteratorAggregate, Countable
- {
- /**
- * Gets the iterator
- *
- * @return ArrayIterator
- */
- public function getIterator(): ArrayIterator
- {
- return new ArrayIterator($this->getIteratorArray());
- }
- /**
- * Returns the count of the iterator array.
- *
- * @return int
- */
- public function count(): int
- {
- return count($this->getIteratorArray());
- }
- /**
- * Returns the array to be used the the iterator.
- *
- * @return array
- */
- abstract protected function getIteratorArray(): array;
- }
|