public function addItem(Item $item)
    {
        if ($this->has($item->name)) {
            throw new DuplicateItemNameException(
                sprintf('An item with name `%s` already exists in the menu `%s`',
                    $item->name, $item->menu->name
                )
            );
        }

        return $this->put($item->name, $item);
    }
public function addItem(Item $item)
    {
        if ($this->has($item->name)) {
            throw new DuplicateItemNameException(
                sprintf('An item with name `%s` already exists in the menu `%s`',
                    $item->name, $item->menu->name
                )
            );
        }

        return $this->put($item->name, $item);
    }
public function addItem ( Item $ item ) { if ( $ this -> has ( $ item -> name ) ) { throw new DuplicateItemNameException ( sprintf ( 'An item with name `%s` already exists in the menu `%s`' , $ item -> name , $ item -> menu -> name ) ) ; } return $ this -> put ( $ item -> name , $ item ) ; }
Add new Item to the collection. Performs check for name uniqueness

@param Item $item

@return $this
@throws DuplicateItemNameException
Add new Item to the collection . Performs check for name uniqueness