FOF30\Model\TreeModel::insideSubtree PHP Method

insideSubtree() public method

Checks if our node is inside the subtree of $otherNode. This is a fast check as only lft and rgt values have to be compared.
public insideSubtree ( TreeModel $otherNode ) : boolean
$otherNode TreeModel
return boolean
    public function insideSubtree(TreeModel $otherNode)
    {
        // Sanity checks on current node position
        if ($this->lft >= $this->rgt) {
            throw new TreeInvalidLftRgtCurrent();
        }
        if ($otherNode->lft >= $otherNode->rgt) {
            throw new TreeInvalidLftRgtOther();
        }
        return $this->lft > $otherNode->lft && $this->rgt < $otherNode->rgt;
    }