for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Roboc\Menu;
use Roboc\Support\Interfaces\MenuItemInterface;
/**
* Class Menu
* @package Roboc\Menu
*/
class Menu
{
* @var string
protected $identifier;
* @var array
protected $items = [];
* @var \Roboc\Support\Interfaces\MenuItemInterface
protected $parent;
* Menu constructor.
* @param string $identifier
public function __construct( $identifier )
$this->identifier = $identifier;
}
* @param MenuItemInterface $item
* @return \Roboc\Support\Interfaces\MenuItemInterface
public function add( MenuItemInterface $item )
$this->items[] = $item;
return $item;
* @param string $title
* @return Item
public function item( $title )
return $this->add( new Item( $this ) )->title( $title );
* @return MenuItemInterface[]
public function items()
return $this->items;
* @return MenuItemInterface
public function parent()
return $this->parent;
* @return bool
public function hasParent()
return $this->parent !== null;
* @param $link
MenuItemInterface|null
This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.
@return
public function getItemByLink( $link )
foreach( $this->items() as $item )
if( $item->getLink() === $link )
if( $item->hasSubMenu() )
$item = $item->getSubMenu()->getItemByLink( $link );
if( $item )
return null;
public function setActive( $link )
$item = $this->getItemByLink( $link );
$item->active( true );
public function setParent( MenuItemInterface $item )
$this->parent = $item;
public function hasItems()
return (bool) count( $this->items );
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.