MenuBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
2
namespace AppBundle\Menu;
3
4
use AppBundle\Security\AuthenticatedUserAwareInterface;
5
use AppBundle\Security\AuthenticatedUserAwareTrait;
6
use Knp\Menu\FactoryInterface;
7
8
class MenuBuilder implements AuthenticatedUserAwareInterface
9
{
10
    use AuthenticatedUserAwareTrait;
11
12
    /** @var FactoryInterface */
13
    private $factory;
14
15
    public function __construct(FactoryInterface $factory)
16
    {
17
        $this->factory = $factory;
18
    }
19
20
    public function createMainMenu(array $options)
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...
21
    {
22
        $menu = $this->factory->createItem('root');
23
24
        $menu->addChild('Home', ['route' => 'homepage'])
25
            ->setExtra('icon', 'home fa-lg');
26
        $menu->addChild('Bookmarks', ['route' => 'bookmark.index'])
27
            ->setExtra('icon', 'bookmark');
28
        $mailItem = $menu->addChild('Mail', ['route' => 'mail.index'])
29
            ->setExtra('icon', 'envelope');
30
        $menu->addChild('K', ['uri' => '#'])
31
            ->setExtra('icon', 'newspaper-o');
32
33
        if (($mailCount = $this->authenticatedUser->getMailCount())) {
34
            $mailItem->setExtra('label', [
35
                'content' => $mailCount,
36
            ]);
37
        }
38
39
        return $menu;
40
    }
41
}
42