protected function validateItem (MenuItem $item)
    {
        // MenuItem has children.
        if (count($item->getChildren()) > 0) {
            foreach ($item->getChildren() as $childItem) {
                if (! $this->validateItem($childItem)) {
                    return false;
                }
            }

            // If there are children, the title cannot be longer than 16 characters.
            if (strlen($item->getTitle()) > 16) {
                return false;
            }
            
            return true;
        }

        // Title cannot be longer than 40 characters.
        if (strlen($item->getTitle()) > 40) {
            return false;
        }

        // URLs cannot be longer than 256 characters.
        if ($item->getType() == MenuItem::URL && strlen($item->getKey()) > 256) {
            return false;
        } elseif (strlen($item->getKey()) > 128) {
            return false;
        } elseif (strlen($item->getKey()) < 1) {
            return false;
        }

        return true;
    }
protected function validateItem (MenuItem $item)
    {
        // MenuItem has children.
        if (count($item->getChildren()) > 0) {
            foreach ($item->getChildren() as $childItem) {
                if (! $this->validateItem($childItem)) {
                    return false;
                }
            }

            // If there are children, the title cannot be longer than 16 characters.
            if (strlen($item->getTitle()) > 16) {
                return false;
            }
            
            return true;
        }

        // Title cannot be longer than 40 characters.
        if (strlen($item->getTitle()) > 40) {
            return false;
        }

        // URLs cannot be longer than 256 characters.
        if ($item->getType() == MenuItem::URL && strlen($item->getKey()) > 256) {
            return false;
        } elseif (strlen($item->getKey()) > 128) {
            return false;
        } elseif (strlen($item->getKey()) < 1) {
            return false;
        }

        return true;
    }
protected function validateItem ( MenuItem $ item ) { // MenuItem has children. if ( count ( $ item -> getChildren ( ) ) > 0 ) { foreach ( $ item -> getChildren ( ) as $ childItem ) { if ( ! $ this -> validateItem ( $ childItem ) ) { return false ; } } // If there are children, the title cannot be longer than 16 characters. if ( strlen ( $ item -> getTitle ( ) ) > 16 ) { return false ; } return true ; } // Title cannot be longer than 40 characters. if ( strlen ( $ item -> getTitle ( ) ) > 40 ) { return false ; } // URLs cannot be longer than 256 characters. if ( $ item -> getType ( ) == MenuItem :: URL && strlen ( $ item -> getKey ( ) ) > 256 ) { return false ; } elseif ( strlen ( $ item -> getKey ( ) ) > 128 ) { return false ; } elseif ( strlen ( $ item -> getKey ( ) ) < 1 ) { return false ; } return true ; }
Validates whether the supplied item qualifies as a valid menu item.

@param MenuItem $item

@return bool
Validates whether the supplied item qualifies as a valid menu item .