public function getChildOfType($type)
    {
        $children = $this->getChildrenOfType($type);

        if (!$children) {
            throw new OutOfBoundsException(sprintf(
                'Expected exactly one child of type "%s", got "%s"',
                $type, count($children)
            ));
        }

        if (count($children) > 1) {
            throw new OutOfBoundsException(sprintf(
                'More than one node of type "%s" but getChildOfType will only ever return one.',
                $type
            ));
        }

        return current($children);
    }
public function getChildOfType($type)
    {
        $children = $this->getChildrenOfType($type);

        if (!$children) {
            throw new OutOfBoundsException(sprintf(
                'Expected exactly one child of type "%s", got "%s"',
                $type, count($children)
            ));
        }

        if (count($children) > 1) {
            throw new OutOfBoundsException(sprintf(
                'More than one node of type "%s" but getChildOfType will only ever return one.',
                $type
            ));
        }

        return current($children);
    }
public function getChildOfType ( $ type ) { $ children = $ this -> getChildrenOfType ( $ type ) ; if ( ! $ children ) { throw new OutOfBoundsException ( sprintf ( 'Expected exactly one child of type "%s", got "%s"' , $ type , count ( $ children ) ) ) ; } if ( count ( $ children ) > 1 ) { throw new OutOfBoundsException ( sprintf ( 'More than one node of type "%s" but getChildOfType will only ever return one.' , $ type ) ) ; } return current ( $ children ) ; }
Return child of specified type.

Note: This does not take inheritance into account.

@param string $type The name of the type.

@throws OutOfBoundsException if there are more than one or none

@return AbstractNode
Return child of specified type .