_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 void */ 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 DOMElement */ 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 void */ public function next() { ++$this->_position; return $this->_nodeList->item($this->_position); } /** * Countable: get count * * @return int */ public function count() { return $this->_nodeList->length; } }