Application   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 34
rs 10

4 Methods

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