Completed
Push — develop ( 4602a5...e9597c )
by Andreas
07:50
created

App   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 80%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 4
dl 0
loc 40
ccs 8
cts 10
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A configureContainer() 0 4 1
A loadModules() 0 11 2
1
<?php
2
namespace Wambo\Core;
3
use DI\ContainerBuilder;
4
use Wambo\Core\Module\Module;
5
use Wambo\Core\Module\ModuleRepository;
6
7
/**
8
 * Class App
9
 * @package Wambo\Core
10
 */
11
class App extends \DI\Bridge\Slim\App
12
{
13
    /**
14
     * @var string
15
     */
16
    private $bootstrapFilePath;
17 1
18
    /**
19 1
     * App constructor.
20 1
     *
21 1
     * @param string $bootstrapFilePath
22
     */
23
    public function __construct(string $bootstrapFilePath)
24
    {
25
        $this->bootstrapFilePath = $bootstrapFilePath;
26 1
27
        parent::__construct();
28
        $this->loadModules();
29 1
    }
30
31
    protected function configureContainer(ContainerBuilder $builder)
32 1
    {
33
        $builder->addDefinitions($this->bootstrapFilePath);
34
    }
35
36 1
    /**
37
     * add modules to App
38
     */
39
    private function loadModules()
40
    {
41
        /** @var ModuleRepository $repo */
42
        $repo = $this->getContainer()->get('module_repository');
43
44
        /** @var Module $module */
45
        foreach ($repo->getAll() as $module) {
46
            $moduleClass = $module->getClass();
47
            new $moduleClass($this);
48
        }
49
    }
50
}