Passed
Push — master ( 410a8e...414ff7 )
by Arnaud
04:38 queued 01:13
created

MenuProvider::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 1
c 3
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Menu\Provider;
6
7
use Knp\Menu\ItemInterface;
8
use Knp\Menu\Provider\MenuProviderInterface;
9
use LAG\AdminBundle\Menu\Factory\MenuFactoryInterface;
10
11
/**
12
 * Create a new KNP menu using the MenuConfiguration class to validate provided options.
13
 */
14
class MenuProvider implements MenuProviderInterface
15
{
16
    private array $menuConfigurations;
17
    private MenuFactoryInterface $menuFactory;
18
19 1
    public function __construct(
20
        array $menuConfigurations,
21
        MenuFactoryInterface $menuFactory
22
    ) {
23 1
        $this->menuConfigurations = $menuConfigurations;
24 1
        $this->menuFactory = $menuFactory;
25 1
    }
26
27 1
    public function get(string $name, array $options = []): ItemInterface
28
    {
29 1
        return $this->menuFactory->create($name, $options);
30
    }
31
32
    public function has(string $name, array $options = []): bool
33
    {
34
        return \array_key_exists($name, $this->menuConfigurations);
35
    }
36
}
37