Completed
Pull Request — master (#29)
by Aleh
03:11
created

Application::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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