App   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 5
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 2
A getConsole() 0 4 1
A setConsole() 0 8 2
1
<?php
2
3
namespace Taisiya\CoreBundle;
4
5
use JBZoo\PimpleDumper\PimpleDumper;
6
use Pimple\Container;
7
use Symfony\Component\Console\Output\ConsoleOutput;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\EventDispatcher\EventDispatcher;
10
use Taisiya\CoreBundle\Exception\RuntimeException;
11
12
final class App extends \Slim\App
13
{
14
    /**
15
     * @var Console
16
     */
17
    private $console;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function __construct($container = [])
23
    {
24
        parent::__construct($container);
25
26
        $this->getContainer()['event_dispatcher'] = function (Container $pimple) {
0 ignored issues
show
Unused Code introduced by
The parameter $pimple is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
            return new EventDispatcher();
28
        };
29
30
        $this->getContainer()['console.output'] = function (Container $pimple) {
0 ignored issues
show
Unused Code introduced by
The parameter $pimple is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
            return new ConsoleOutput(OutputInterface::VERBOSITY_VERBOSE);
32
        };
33
34
        if (class_exists(PimpleDumper::class)) {
35
            $this->getContainer()->register(new PimpleDumper());
36
        }
37
    }
38
39
    /**
40
     * @return Console
41
     */
42
    public function getConsole(): Console
43
    {
44
        return $this->console;
45
    }
46
47
    /**
48
     * @param Console $console
49
     *
50
     * @throws RuntimeException
51
     */
52
    public function setConsole(Console $console): void
53
    {
54
        if ($this->console) {
55
            throw new RuntimeException('Console already sets');
56
        }
57
58
        $this->console = $console;
59
    }
60
}
61