Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ElementCollection.php

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\Manifest
View 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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal