src/ParametricTree/RecursiveTree.php
public function buildLeaf($uniqueKey = null, $parentKey = null)
    {
        if (isset($this->crown[$uniqueKey])) {
            throw new InvalidArgumentException(sprintf(
                'The leaf with key "%s" is already exists.',
                $uniqueKey
            ));
        }
        if ($parentKey && ! isset($this->crown[$parentKey])) {
            throw new InvalidArgumentException(sprintf(
                'Unknown leaf "%s" specified as parent.',
                $parentKey
            ));
        }
        $leaf = clone $this->getLeafPrototype();
        $this->injectInCrown($leaf, $uniqueKey);

        if ($parentKey) {
            $parent = $this->crown[$parentKey];
            $parent->addChild($leaf);
        } else {
            $this->branch[$leaf->getUniqueKey()] = $leaf;
            $leaf->setDepth(0);
        }

        return $leaf;
    }
public function buildLeaf($uniqueKey = null, $parentKey = null)
    {
        if (isset($this->crown[$uniqueKey])) {
            throw new InvalidArgumentException(sprintf(
                'The leaf with key "%s" is already exists.',
                $uniqueKey
            ));
        }
        if ($parentKey && ! isset($this->crown[$parentKey])) {
            throw new InvalidArgumentException(sprintf(
                'Unknown leaf "%s" specified as parent.',
                $parentKey
            ));
        }
        $leaf = clone $this->getLeafPrototype();
        $this->injectInCrown($leaf, $uniqueKey);

        if ($parentKey) {
            $parent = $this->crown[$parentKey];
            $parent->addChild($leaf);
        } else {
            $this->branch[$leaf->getUniqueKey()] = $leaf;
            $leaf->setDepth(0);
        }

        return $leaf;
    }
public function buildLeaf ( $ uniqueKey = null , $ parentKey = null ) { if ( isset ( $ this -> crown [ $ uniqueKey ] ) ) { throw new InvalidArgumentException ( sprintf ( 'The leaf with key "%s" is already exists.' , $ uniqueKey ) ) ; } if ( $ parentKey && ! isset ( $ this -> crown [ $ parentKey ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Unknown leaf "%s" specified as parent.' , $ parentKey ) ) ; } $ leaf = clone $ this -> getLeafPrototype ( ) ; $ this -> injectInCrown ( $ leaf , $ uniqueKey ) ; if ( $ parentKey ) { $ parent = $ this -> crown [ $ parentKey ] ; $ parent -> addChild ( $ leaf ) ; } else { $ this -> branch [ $ leaf -> getUniqueKey ( ) ] = $ leaf ; $ leaf -> setDepth ( 0 ) ; } return $ leaf ; }
Builds the leaf.

@param null|int|string $uniqueKey Optional; null by default. The key,
which is unique within the tree
@param null|int|string $parentKey Optional; null by default. The key of
parent leaf

@throws \InvalidArgumentException
Builds the leaf .