Source of file NodeList.php
Size: 4,274 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Dom/NodeList.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Dom; use ArrayAccess; use Countable; use DOMDocument; use DOMNodeList; use DOMNode; use Iterator; /** * Nodelist for DOM XPath query * @deprecated * @see \Zend\Dom\Document\NodeList */ class NodeList implements Iterator, Countable, ArrayAccess { /** * CSS Selector query * @var string */ protected $cssQuery; /** * @var DOMDocument */ protected $document; /** * @var DOMNodeList */ protected $nodeList; /** * Current iterator position * @var int */ protected $position = 0; /** * XPath query * @var string */ protected $xpathQuery; /** * Constructor * * @param string $cssQuery * @param string|array $xpathQuery * @param DOMDocument $document * @param DOMNodeList $nodeList */ public function __construct($cssQuery, $xpathQuery, DOMDocument $document, DOMNodeList $nodeList) { $this->cssQuery = $cssQuery; $this->xpathQuery = $xpathQuery; $this->document = $document; $this->nodeList = $nodeList; } /** * Retrieve CSS Query * * @return string */ public function getCssQuery() { return $this->cssQuery; } /** * Retrieve XPath query * * @return string */ public function getXpathQuery() { return $this->xpathQuery; } /** * Retrieve DOMDocument * * @return DOMDocument */ public function getDocument() { return $this->document; } /** * Iterator: rewind to first element * * @return DOMNode */ public function rewind() { $this->position = 0; return $this->nodeList->item(0); } /** * Iterator: is current position valid? * * @return bool */ public function valid() { if (in_array($this->position, range(0, $this->nodeList->length - 1)) && $this->nodeList->length > 0) { return true; } return false; } /** * Iterator: return current element * * @return DOMNode */ public function current() { return $this->nodeList->item($this->position); } /** * Iterator: return key of current element * * @return int */ public function key() { return $this->position; } /** * Iterator: move to next element * * @return DOMNode */ public function next() { ++$this->position; return $this->nodeList->item($this->position); } /** * Countable: get count * * @return int */ public function count() { return $this->nodeList->length; } /** * ArrayAccess: offset exists * * @param int $key * @return bool */ public function offsetExists($key) { if (in_array($key, range(0, $this->nodeList->length - 1)) && $this->nodeList->length > 0) { return true; } return false; } /** * ArrayAccess: get offset * * @param int $key * @return mixed */ public function offsetGet($key) { return $this->nodeList->item($key); } /** * ArrayAccess: set offset * * @param mixed $key * @param mixed $value * @throws Exception\BadMethodCallException when attemptingn to write to a read-only item */ public function offsetSet($key, $value) { throw new Exception\BadMethodCallException('Attempting to write to a read-only list'); } /** * ArrayAccess: unset offset * * @param mixed $key * @throws Exception\BadMethodCallException when attemptingn to unset a read-only item */ public function offsetUnset($key) { throw new Exception\BadMethodCallException('Attempting to unset on a read-only list'); } } |