for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the CMS Kernel library.
*
* Copyright (c) 2016 LIN3S <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace LIN3S\CMSKernel\Domain\Model\Menu;
use LIN3S\SharedKernel\Domain\Model\Collection;
use LIN3S\SharedKernel\Domain\Model\CollectionElementAlreadyRemovedException;
/**
* @author Beñat Espiña <[email protected]>
class MenuItemCollection extends Collection
{
protected function type()
return MenuItem::class;
}
public function removeById(MenuItemId $menuItemId)
$menuItems = $this->toArray();
foreach ($menuItems as $item) {
if ($menuItemId->equals($item->id())) {
$this->remove($item);
return;
throw new CollectionElementAlreadyRemovedException();