| Total Complexity | 7 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 20 | class FooExtensionMenu implements ExtensionMenuInterface |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var FactoryInterface |
||
| 24 | */ |
||
| 25 | private $factory; |
||
| 26 | |||
| 27 | public function __construct( |
||
| 28 | FactoryInterface $factory |
||
| 29 | ) { |
||
| 30 | $this->factory = $factory; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function get(string $type = self::TYPE_ADMIN): ?ItemInterface |
||
| 34 | { |
||
| 35 | if (self::TYPE_ADMIN === $type) { |
||
| 36 | return $this->getAdmin(); |
||
| 37 | } |
||
| 38 | if (self::TYPE_USER === $type) { |
||
| 39 | return $this->getUser(); |
||
| 40 | } |
||
| 41 | |||
| 42 | return null; |
||
| 43 | } |
||
| 44 | |||
| 45 | private function getAdmin(): ?ItemInterface |
||
| 46 | { |
||
| 47 | $menu = $this->factory->createItem('foo'); |
||
| 48 | $menu->addChild('list', [ |
||
| 49 | 'route' => 'list', |
||
| 50 | ]); |
||
| 51 | $menu->addChild('foo', [ |
||
| 52 | 'route' => 'foo', |
||
| 53 | ]); |
||
| 54 | $menu->addChild('bar', [ |
||
| 55 | 'route' => 'bar', |
||
| 56 | ]); |
||
| 57 | |||
| 58 | return $menu; |
||
| 59 | } |
||
| 60 | |||
| 61 | private function getUser(): ?ItemInterface |
||
| 69 | } |
||
| 70 | |||
| 71 | public function getBundleName(): string |
||
| 74 | } |
||
| 75 | } |
||
| 76 |