DiDom\Document::is PHP Method

is() public method

Indicates if two documents are the same document.
public is ( Document | DOMDocument $document ) : boolean
$document Document | DOMDocument The compared document
return boolean
    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);
    }

Usage Example

Beispiel #1
0
 public function testIs()
 {
     $html = $this->loadFixture('posts.html');
     $document = new Document($html, false);
     $document2 = new Document($html, false);
     $this->assertTrue($document->is($document));
     $this->assertFalse($document->is($document2));
 }
All Usage Examples Of DiDom\Document::is