AdminMenuBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 48
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createMenu() 0 9 1
A addCustomerSubMenu() 0 13 1
A addConfigurationSubMenu() 0 13 1
1
<?php
2
3
/*
4
 * This file is part of AppName.
5
 *
6
 * (c) Monofony
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Menu;
13
14
use Knp\Menu\FactoryInterface;
15
use Knp\Menu\ItemInterface;
16
17
final class AdminMenuBuilder
18
{
19
    /** @var FactoryInterface */
20
    private $factory;
21
22
    public function __construct(FactoryInterface $factory)
23
    {
24
        $this->factory = $factory;
25
    }
26
27
    public function createMenu(array $options): ItemInterface
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29
        $menu = $this->factory->createItem('root');
30
31
        $this->addCustomerSubMenu($menu);
32
        $this->addConfigurationSubMenu($menu);
33
34
        return $menu;
35
    }
36
37
    private function addCustomerSubMenu(ItemInterface $menu): ItemInterface
38
    {
39
        $customer = $menu
40
            ->addChild('customer')
41
            ->setLabel('sylius.ui.customer')
42
        ;
43
44
        $customer->addChild('backend_customer', ['route' => 'sylius_backend_customer_index'])
45
            ->setLabel('sylius.ui.customers')
46
            ->setLabelAttribute('icon', 'users');
47
48
        return $customer;
49
    }
50
51
    private function addConfigurationSubMenu(ItemInterface $menu): ItemInterface
52
    {
53
        $configuration = $menu
54
            ->addChild('configuration')
55
            ->setLabel('sylius.ui.configuration')
56
        ;
57
58
        $configuration->addChild('backend_admin_user', ['route' => 'sylius_backend_admin_user_index'])
59
            ->setLabel('sylius.ui.admin_users')
60
            ->setLabelAttribute('icon', 'lock');
61
62
        return $configuration;
63
    }
64
}
65