public function validate()
    {
        $cardinalityMap = $this->getCardinalityMap();
        $typeCount = [];

        foreach (array_keys($cardinalityMap) as $type) {
            $typeCount[$type] = 0;
        }

        foreach ($this->children as $type => $children) {
            $typeCount[$type] += count($children);
        }

        foreach ($typeCount as $type => $count) {
            list($min, $max) = $cardinalityMap[$type];
            if (null !== $min && $count < $min) {
                throw new OutOfBoundsException(sprintf(
                    'QueryBuilder node "%s" must have at least "%s" '.
                    'child nodes of type "%s". "%s" given.',
                    $this->getName(),
                    $min,
                    $type,
                    $count
                ));
            }
        }
    }
public function validate()
    {
        $cardinalityMap = $this->getCardinalityMap();
        $typeCount = [];

        foreach (array_keys($cardinalityMap) as $type) {
            $typeCount[$type] = 0;
        }

        foreach ($this->children as $type => $children) {
            $typeCount[$type] += count($children);
        }

        foreach ($typeCount as $type => $count) {
            list($min, $max) = $cardinalityMap[$type];
            if (null !== $min && $count < $min) {
                throw new OutOfBoundsException(sprintf(
                    'QueryBuilder node "%s" must have at least "%s" '.
                    'child nodes of type "%s". "%s" given.',
                    $this->getName(),
                    $min,
                    $type,
                    $count
                ));
            }
        }
    }
public function validate ( ) { $ cardinalityMap = $ this -> getCardinalityMap ( ) ; $ typeCount = [ ] ; foreach ( array_keys ( $ cardinalityMap ) as $ type ) { $ typeCount [ $ type ] = 0 ; } foreach ( $ this -> children as $ type => $ children ) { $ typeCount [ $ type ] += count ( $ children ) ; } foreach ( $ typeCount as $ type => $ count ) { list ( $ min , $ max ) = $ cardinalityMap [ $ type ] ; if ( null !== $ min && $ count < $ min ) { throw new OutOfBoundsException ( sprintf ( 'QueryBuilder node "%s" must have at least "%s" ' . 'child nodes of type "%s". "%s" given.' , $ this -> getName ( ) , $ min , $ type , $ count ) ) ; } } }
Validate the current node.

Validation is performed both when the query is being
built and when the dev explicitly calls "end()".

This method simply checks the minimum boundries are satisfied,
the addChild() method already validates maximum boundries and
types.

@throws OutOfBoundsException
Validate the current node .