FOF30\Model\TreeModel::isLeaf PHP Метод

isLeaf() публичный Метод

Is this a leaf node (a node without children)?
public isLeaf ( ) : boolean
Результат boolean
    public function isLeaf()
    {
        // Sanity checks on current node position
        if ($this->lft >= $this->rgt) {
            throw new TreeInvalidLftRgtCurrent();
        }
        return $this->rgt - 1 == $this->lft;
    }

Usage Example

Пример #1
0
 /**
  * Returns true if both this node and $otherNode are root, leaf or child (same tree scope)
  *
  * @param TreeModel $otherNode
  *
  * @return bool
  */
 public function inSameScope(TreeModel $otherNode)
 {
     if ($this->isLeaf()) {
         return $otherNode->isLeaf();
     } elseif ($this->isRoot()) {
         return $otherNode->isRoot();
     } elseif ($this->isChild()) {
         return $otherNode->isChild();
     } else {
         return false;
     }
 }