Exemplo n.º 1
0
 /**
  * Find out if node has (a certain) parent
  * @param HTML_Node|string $tag Match against parent, string to match tag, object to fully match node, null to return if node has parent
  * @param bool $recursive
  * @return bool
  */
 function hasParent($tag = null, $recursive = false)
 {
     if ($this->parent !== null) {
         if ($tag === null) {
             return true;
         } elseif (is_string($tag)) {
             return $this->parent->tag === $tag || $recursive && $this->parent->hasParent($tag);
         } elseif (is_object($tag)) {
             return $this->parent === $tag || $recursive && $this->parent->hasParent($tag);
         }
     }
     return false;
 }