MenuBuilder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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