diff --git a/src/Query.php b/src/Query.php index bc17d9a..87e7dbe 100644 --- a/src/Query.php +++ b/src/Query.php @@ -32,37 +32,37 @@ class Query /** * @var string */ - protected $_document; + protected $document; /** * DOMDocument errors, if any * @var false|array */ - protected $_documentErrors = false; + protected $documentErrors = false; /** * Document type * @var string */ - protected $_docType; + protected $docType; /** * Document encoding * @var null|string */ - protected $_encoding; + protected $encoding; /** * XPath namespaces * @var array */ - protected $_xpathNamespaces = array(); + protected $xpathNamespaces = array(); /** * XPath PHP Functions * @var mixed */ - protected $_xpathPhpFunctions; + protected $xpathPhpFunctions; /** * Constructor @@ -80,11 +80,11 @@ public function __construct($document = null, $encoding = null) * Set document encoding * * @param string $encoding - * @return \Zend\Dom\Query + * @return Query */ public function setEncoding($encoding) { - $this->_encoding = (null === $encoding) ? null : (string) $encoding; + $this->encoding = (null === $encoding) ? null : (string) $encoding; return $this; } @@ -95,7 +95,7 @@ public function setEncoding($encoding) */ public function getEncoding() { - return $this->_encoding; + return $this->encoding; } /** @@ -103,7 +103,7 @@ public function getEncoding() * * @param string $document * @param null|string $encoding Document encoding - * @return \Zend\Dom\Query + * @return Query */ public function setDocument($document, $encoding = null) { @@ -113,7 +113,7 @@ public function setDocument($document, $encoding = null) // breaking XML declaration to make syntax highlighting work if ('<' . '?xml' == substr(trim($document), 0, 5)) { if (preg_match('/]*xmlns="([^"]+)"[^>]*>/i', $document, $matches)) { - $this->_xpathNamespaces[] = $matches[1]; + $this->xpathNamespaces[] = $matches[1]; return $this->setDocumentXhtml($document, $encoding); } return $this->setDocumentXml($document, $encoding); @@ -129,12 +129,12 @@ public function setDocument($document, $encoding = null) * * @param string $document * @param null|string $encoding Document encoding - * @return \Zend\Dom\Query + * @return Query */ public function setDocumentHtml($document, $encoding = null) { - $this->_document = (string) $document; - $this->_docType = self::DOC_HTML; + $this->document = (string) $document; + $this->docType = self::DOC_HTML; if (null !== $encoding) { $this->setEncoding($encoding); } @@ -146,12 +146,12 @@ public function setDocumentHtml($document, $encoding = null) * * @param string $document * @param null|string $encoding Document encoding - * @return \Zend\Dom\Query + * @return Query */ public function setDocumentXhtml($document, $encoding = null) { - $this->_document = (string) $document; - $this->_docType = self::DOC_XHTML; + $this->document = (string) $document; + $this->docType = self::DOC_XHTML; if (null !== $encoding) { $this->setEncoding($encoding); } @@ -163,12 +163,12 @@ public function setDocumentXhtml($document, $encoding = null) * * @param string $document * @param null|string $encoding Document encoding - * @return \Zend\Dom\Query + * @return Query */ public function setDocumentXml($document, $encoding = null) { - $this->_document = (string) $document; - $this->_docType = self::DOC_XML; + $this->document = (string) $document; + $this->docType = self::DOC_XML; if (null !== $encoding) { $this->setEncoding($encoding); } @@ -182,7 +182,7 @@ public function setDocumentXml($document, $encoding = null) */ public function getDocument() { - return $this->_document; + return $this->document; } /** @@ -192,7 +192,7 @@ public function getDocument() */ public function getDocumentType() { - return $this->_docType; + return $this->docType; } /** @@ -202,7 +202,7 @@ public function getDocumentType() */ public function getDocumentErrors() { - return $this->_documentErrors; + return $this->documentErrors; } /** @@ -252,7 +252,7 @@ public function queryXpath($xpathQuery, $query = null) } $errors = libxml_get_errors(); if (!empty($errors)) { - $this->_documentErrors = $errors; + $this->documentErrors = $errors; libxml_clear_errors(); } libxml_use_internal_errors(false); @@ -261,30 +261,30 @@ public function queryXpath($xpathQuery, $query = null) throw new Exception\RuntimeException(sprintf('Error parsing document (type == %s)', $type)); } - $nodeList = $this->_getNodeList($domDoc, $xpathQuery); + $nodeList = $this->getNodeList($domDoc, $xpathQuery); return new NodeList($query, $xpathQuery, $domDoc, $nodeList); } /** * Register XPath namespaces * - * @param array $xpathNamespaces - * @return void + * @param array $xpathNamespaces + * @return void */ public function registerXpathNamespaces($xpathNamespaces) { - $this->_xpathNamespaces = $xpathNamespaces; + $this->xpathNamespaces = $xpathNamespaces; } /** * Register PHP Functions to use in internal DOMXPath * - * @param mixed $restrict + * @param mixed $restrict * @return void */ public function registerXpathPhpFunctions($xpathPhpFunctions = true) { - $this->_xpathPhpFunctions = $xpathPhpFunctions; + $this->xpathPhpFunctions = $xpathPhpFunctions; } /** @@ -294,17 +294,17 @@ public function registerXpathPhpFunctions($xpathPhpFunctions = true) * @param string|array $xpathQuery * @return array */ - protected function _getNodeList($document, $xpathQuery) + protected function getNodeList($document, $xpathQuery) { $xpath = new DOMXPath($document); - foreach ($this->_xpathNamespaces as $prefix => $namespaceUri) { + foreach ($this->xpathNamespaces as $prefix => $namespaceUri) { $xpath->registerNamespace($prefix, $namespaceUri); } - if ($this->_xpathPhpFunctions) { + if ($this->xpathPhpFunctions) { $xpath->registerNamespace("php", "http://php.net/xpath"); - ($this->_xpathPhpFunctions === true) ? + ($this->xpathPhpFunctions === true) ? $xpath->registerPHPFunctions() - : $xpath->registerPHPFunctions($this->_xpathPhpFunctions); + : $xpath->registerPHPFunctions($this->xpathPhpFunctions); } $xpathQuery = (string) $xpathQuery; return $xpath->query($xpathQuery);