AbstractMenuBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 35
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Bundle\UiBundle\Menu;
13
14
use Knp\Menu\FactoryInterface;
15
use Knp\Menu\ItemInterface;
16
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
17
18
/**
19
 * @author GeLo <[email protected]>
20
 */
21
abstract class AbstractMenuBuilder implements MenuBuilderInterface
22
{
23
    /**
24
     * @var FactoryInterface
25
     */
26
    private $factory;
27
28
    /**
29
     * @var EventDispatcherInterface
30
     */
31
    private $eventDispatcher;
32
33
    /**
34
     * @param FactoryInterface         $factory
35
     * @param EventDispatcherInterface $eventDispatcher
36
     */
37 2
    public function __construct(FactoryInterface $factory, EventDispatcherInterface $eventDispatcher)
38
    {
39 2
        $this->factory = $factory;
40 2
        $this->eventDispatcher = $eventDispatcher;
41 2
    }
42
43
    /**
44
     * @return ItemInterface
45
     */
46 1
    public function create()
47
    {
48 1
        $this->eventDispatcher->dispatch(MenuBuilderEvents::BUILD, $event = new MenuBuilderEvent(
49 1
            $this->factory,
50 1
            $this->factory->createItem($this->getName())
51 1
        ));
52
53 1
        return $event->getItem();
54
    }
55
}
56