Completed
Push — master ( 5bda77...cb2c73 )
by Aleh
10s
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
define("STUBS_DIR", dirname(dirname(dirname(__DIR__))) . '/stubs');
11
12
/**
13
 * Class Application
14
 */
15
abstract class Application extends BaseApplication
16
{
17
    public function __construct($name = "Padawan")
18
    {
19
        parent::__construct($name, PADAWAN_VERSION);
20
        $this->createContainer();
21
        $this->setAutoExit(false);
22
        $this->loadCommands();
23
    }
24
25
    public function getContainer()
26
    {
27
        return $this->container;
28
    }
29
30
    abstract protected function loadCommands();
31
32
    private function createContainer()
33
    {
34
        $builder = new ContainerBuilder;
35
        $builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache);
36
        $builder->addDefinitions(__DIR__ . '/DI/config.php');
37
        $this->container = $builder->build();
38
    }
39
40
    /** @var Container */
41
    protected $container;
42
}
43