Indicates if two documents are the same document.

@param \DiDom\Document|\DOMDocument $document The compared document

@return bool

@throws \InvalidArgumentException if the provided argument is not an instance of \DOMDocument or \DiDom\Document
766423
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 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);
    }
119040
private function extractResumeToken($document)
    {
        if ( ! is_array($document) && ! is_object($document)) {
            throw InvalidArgumentException::invalidType('$document', $document, 'array or object');
        }

        if ($document instanceof Serializable) {
            return $this->extractResumeToken($document->bsonSerialize());
        }

        $resumeToken = is_array($document)
            ? (isset($document['_id']) ? $document['_id'] : null)
            : (isset($document->_id) ? $document->_id : null);

        if ( ! isset($resumeToken)) {
            throw ResumeTokenException::notFound();
        }

        if ( ! is_array($resumeToken) && ! is_object($resumeToken)) {
            throw ResumeTokenException::invalidType($resumeToken);
        }

        return $resumeToken;
    }
893270
public function has($identifier)
    {
        $this->normalizeToPath($identifier);

        try {
            $this->find($identifier);

            return true;
        } catch (DocumentNotFoundException $e) {
            return false;
        }
    }
832137
public function deleteDocument(\Document $document)
  {
    $objStmt = $this->Database->prepare("DELETE FROM tl_dms_documents WHERE id=?")->execute($document->id);
    
    return ($objStmt->affectedRows > 0);
  }
1233365
protected function compareCollection(DocumentSchema $document)
    {
        if ($document->getDatabase() != $this->schema->getDatabase()) {
            return false;
        }

        return $document->getCollection() == $this->schema->getCollection();
    }
191997
public function exists(object $document) : bool
    {
        $id = $this->class->getIdentifierObject($document);
        assert($this->collection instanceof Collection);
        return (bool) $this->collection->findOne(['_id' => $id], ['_id']);
    }
25782
public function unlock($document)
    {
        if ($this->getDocumentState($document) != self::STATE_MANAGED) {
            throw new \InvalidArgumentException("Document is not MANAGED.");
        }
        $documentName = get_class($document);
        $this->getDocumentPersister($documentName)->unlock($document);
    }
772797
public static boolean compare(Document d1, Document d2) throws MarshalException {
		d1.normalize();
		d2.normalize();
		return d1.isEqualNode(d2);
	}
1292850
public function cloneNode(\DOMDocument $domDocument)
    {
        return $domDocument->importNode($this->getDomNode()->cloneNode(false), false);
    }
862830
public function exists($document)
    {
        $id = $this->class->getIdentifierObject($document);
        return (boolean) $this->collection->findOne(array('_id' => $id), array('_id'));
    }
636710
static public function inferVersion(DOMDocument $document)
    {
        $root = $document->documentElement;
        $version = false;
        
        if (empty($root) === false) {
            $rootNs = $root->namespaceURI;
            
            if ($rootNs === 'http://www.imsglobal.org/xsd/imsqti_v2p0') {
                $nsLocation = self::getXsdLocation($document, 'http://www.imsglobal.org/xsd/imsqti_v2p0');
                
                if ($nsLocation === 'http://www.imsglobal.org/xsd/imsqti_v2p0.xsd') {
                    $version = '2.0.0';
                }
            } elseif ($rootNs === 'http://www.imsglobal.org/xsd/imsqti_v2p1') {
                $nsLocation = self::getXsdLocation($document, 'http://www.imsglobal.org/xsd/imsqti_v2p1');
                
                if ($nsLocation === 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd') {
                    $version = '2.1.0';
                } else if ($nsLocation === 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1p1.xsd') {
                    $version = '2.1.1';
                }
            } elseif ($rootNs === 'http://www.imsglobal.org/xsd/imsqti_v2p2') {
                $nsLocation = self::getXsdLocation($document, 'http://www.imsglobal.org/xsd/imsqti_v2p2');
                
                if ($nsLocation === 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd') {
                    $version = '2.2.0';
                } elseif ($nsLocation === 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p1.xsd') {
                    $version = '2.2.1';
                }
            } elseif ($rootNs === 'http://www.imsglobal.org/xsd/imsaqti_item_v1p0') {
                $nsLocation = self::getXsdLocation($document, 'http://www.imsglobal.org/xsd/imsaqti_item_v1p0');
                
                if ($nsLocation === 'http://www.imsglobal.org/xsd/qti/aqtiv1p0/imsaqti_itemv1p0_v1p0.xsd') {
                    $version = '3.0.0';
                }
            }
        }
        
        return $version;
    }
59402
protected function appendPhpdocStatsElement(\DOMDocument $document)
    {
        $stats = $document->createElement('phpdoc-stats');
        $stats->setAttribute('version', Application::VERSION());
        $document->appendChild($stats);

        return $document;
    }
137502
public function isDocumentScheduled(object $document) : bool
    {
        $oid = spl_object_hash($document);
        return isset($this->documentInsertions[$oid]) ||
            isset($this->documentUpserts[$oid]) ||
            isset($this->documentUpdates[$oid]) ||
            isset($this->documentDeletions[$oid]);
    }
972475
private function ensureExistenceOfBodyElement(\DOMDocument $document)
    {
        if ($document->getElementsByTagName('body')->item(0) !== null) {
            return;
        }

        $htmlElement = $document->getElementsByTagName('html')->item(0);

        $htmlElement->appendChild($document->createElement('body'));
    }
215793
public function exists($document)
    {
        $identifier = $this->class->createIdentifier($document);
        $qb         = $this->dm->createQueryBuilder($this->class->name);
        $query      = $qb->get()->setIdentifier($identifier)->getQuery();

        return (boolean)$query->getSingleMarshalledResult();
    }
176942
public function is($node)
    {
        if ($node instanceof Element) {
            $node = $node->getNode();
        }

        if (!$node instanceof DOMNode) {
            throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s or DOMNode, %s given', __METHOD__, __CLASS__, (is_object($node) ? get_class($node) : gettype($node))));
        }

        return $this->node->isSameNode($node);
    }
329625
public function isInIdentityMap($document)
    {
        $oid = spl_object_hash($document);

        if ( ! isset($this->documentIdentifiers[$oid])) {
            return false;
        }

        $class = $this->dm->getClassMetadata(get_class($document));

        if ( ! $class->identifier) {
            $id = spl_object_hash($document);
        } else {
            $id = $this->documentIdentifiers[spl_object_hash($document)];
            $id = serialize($class->getDatabaseIdentifierValue($id));
        }

        return isset($this->identityMap[$class->name][$id]);
    }