示例#1
0
 public function equals(BaseNode $node)
 {
     if ($this->getIntegerMode() === $node->getIntegerMode() && $this->getName() === $node->getName()) {
         $our_related = $this->getRelatedObject();
         $theirs_related = $node->getRelatedObject();
         // When the objects are new, or both proxies or non-proxies
         if ($our_related == $theirs_related) {
             return true;
         } else {
             // When at least one of the objects are proxies
             if ($our_related->getSha() != "" && $theirs_related->getSha() != "") {
                 // SHA string comparison has to be with ===
                 return $our_related->getSha() === $theirs_related->getSha();
             }
         }
     }
     return false;
 }
示例#2
0
 /**
  * Attache node to tree
  * @param BaseNode $node
  * @throws NodeWithKeyAlreadyExistException
  */
 protected function attacheNode(BaseNode $node)
 {
     if (array_key_exists($node->getKey(), $this->nodes)) {
         throw new NodeWithKeyAlreadyExistException($node->getKey());
     }
     if ($node->getParentNode() === NULL) {
         $this->roots[$node->getKey()] = $node;
     } else {
         $this->nodes[$node->getParentNode()->getKey()]->addNode($node);
     }
     $this->nodes[$node->getKey()] = $node;
 }