MenuProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 28
c 2
b 2
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 3 1
A register() 0 21 1
1
<?php
2
3
namespace Dominikzogg\EnergyCalculator\Provider;
4
5
use Dominikzogg\EnergyCalculator\Menu\MenuBuilder;
6
use Silex\Application;
7
use Silex\ServiceProviderInterface;
8
9
class MenuProvider implements ServiceProviderInterface
10
{
11
    public function register(Application $app)
12
    {
13
        $app['menu_builder'] = $app->share(function (Application $app) {
14
            return new MenuBuilder(
15
                $app['knp_menu.factory'],
16
                $app['security.authorization_checker'],
17
                $app['security.token_storage'],
18
                $app['translator']
19
            );
20
        });
21
22
        $app['main_menu'] = function (Application $app) {
23
            $menuBuilder = $app['menu_builder'];
24
            /** @var MenuBuilder $menuBuilder */
25
            return $menuBuilder->buildMenu($app['request']);
26
        };
27
28
        $knpMenuMenus = $app['knp_menu.menus'];
29
        $knpMenuMenus['main'] = 'main_menu';
30
        $app['knp_menu.menus'] = $knpMenuMenus;
31
    }
32
33
    public function boot(Application $app)
34
    {
35
    }
36
}
37