ControllersService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getControllers() 0 6 1
A registerControllers() 0 7 3
1
<?php
2
/**
3
 * Copyright (c) 2017
4
 *
5
 * @package   Majima
6
 * @author    David Neustadt <[email protected]>
7
 * @copyright 2017 David Neustadt
8
 * @license   MIT
9
 */
10
11
namespace Majima\Services;
12
13
use Majima\Controller\AdminController;
14
use Majima\Controller\IndexController;
15
use Majima\Controller\InstallController;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
/**
20
 * Class ControllersService
21
 * @package Majima\Services
22
 */
23
class ControllersService implements ControllersServiceInterface
24
{
25
    /**
26
     * @return array
27
     */
28
    public function getControllers()
29
    {
30
        return [
31
            'majima.admin_controller' => AdminController::class,
32
            'majima.index_controller' => IndexController::class,
33
            'majima.install_controller' => InstallController::class,
34
        ];
35
    }
36
37
    /**
38
     * @param ContainerBuilder $container
39
     */
40
    public function registerControllers(ContainerBuilder $container)
41
    {
42
        foreach ($this->getControllers() as $id => $class) {
43
            if (!$container->has($id)) {
44
                $container->register($id, $class)
45
                    ->addArgument(new Reference('service_container'))
46
                    ->addArgument(new Reference('router'));
47
            }
48
        }
49
    }
50
}