Completed
Pull Request — master (#29)
by Aleh
06:28
created

Application   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getContainer() 0 4 1
loadCommands() 0 1 ?
A createContainer() 0 7 1
1
<?php
2
3
namespace Padawan\Framework;
4
5
use DI\Container;
6
use DI\ContainerBuilder;
7
use Symfony\Component\Console\Application as BaseApplication;
8
9
define("PADAWAN_VERSION", "0.3");
10
11
/**
12
 * Class Application
13
 */
14
abstract class Application extends BaseApplication
15
{
16
    public function __construct($name = "Padawan")
17
    {
18
        parent::__construct($name, PADAWAN_VERSION);
19
        $this->createContainer();
20
        $this->setAutoExit(false);
21
        $this->loadCommands();
22
    }
23
24
    public function getContainer()
25
    {
26
        return $this->container;
27
    }
28
29
    abstract protected function loadCommands();
30
31
    private function createContainer()
32
    {
33
        $builder = new ContainerBuilder;
34
        $builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache);
35
        $builder->addDefinitions(__DIR__ . '/DI/config.php');
36
        $this->container = $builder->build();
37
    }
38
39
    /** @var Container */
40
    protected $container;
41
}
42