Example #1
0
 /**
  * Indicates if two documents are the same document.
  * 
  * @param Document|\DOMDocument $document The compared document
  *
  * @return bool
  *
  * @throws \InvalidArgumentException if the provided argument is not an instance of \DOMDocument or \DiDom\Document
  */
 public function is($document)
 {
     if ($document instanceof self) {
         $element = $document->getElement();
     } else {
         if (!$document instanceof DOMDocument) {
             throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s or DOMDocument, %s given', __METHOD__, __CLASS__, is_object($document) ? get_class($document) : gettype($document)));
         }
         $element = $document->documentElement;
     }
     if ($element === null) {
         return false;
     }
     return $this->getElement()->isSameNode($element);
 }
Example #2
0
 /**
  * @param  Document|\DOMDocument $document
  * @return bool
  * @throws \InvalidArgumentException
  */
 public function is($document)
 {
     if ($document instanceof Document) {
         $element = $document->getElement();
     } else {
         if (!$document instanceof DOMDocument) {
             throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s or %s, %s given', __METHOD__, __CLASS__, 'DOMDocument', gettype($document)));
         }
         $element = $document->documentElement;
     }
     return $this->getElement()->isSameNode($element);
 }