Completed
Push — master ( d7cb5b...31c113 )
by Nikita
11:15
created

App::getConsole()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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