ConsoleApplication   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 61.11%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 15
c 3
b 0
f 0
dl 0
loc 37
ccs 11
cts 18
cp 0.6111
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 22 4
A run() 0 3 1
A getSymfonyApplication() 0 3 1
1
<?php declare(strict_types = 1);
2
3
/**
4
 * This file is part of the Simplex package.
5
 *
6
 * (c) Freddie Frantzen <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Simplex;
12
13
use Psr\Container\ContainerInterface;
14
use Symfony\Component\Console\Application;
15
use Symfony\Component\Console\Command\Command;
16
17
class ConsoleApplication
18
{
19
    /** @var Application */
20
    private $symfonyApplication;
21
22 1
    public function __construct(ContainerInterface $container)
23
    {
24 1
        if (!$container->has(ContainerKeys::CONSOLE_COMMANDS)) {
25
            $this->symfonyApplication = new Application();
26
            return;
27
        }
28
29 1
        $application = new Application();
30
31 1
        if ($container->has(ContainerKeys::CONSOLE_HELPER_SET)) {
32
            $helperSet = $container->get(ContainerKeys::CONSOLE_HELPER_SET);
33
            $application->setHelperSet($helperSet);
34
        }
35
36 1
        $commands = $container->get(ContainerKeys::CONSOLE_COMMANDS);
37
38
        /** @var Command $command */
39 1
        foreach ($commands as $command) {
40 1
            $application->add($command);
41
        }
42
43 1
        $this->symfonyApplication = $application;
44 1
    }
45
46
    public function run(): void
47
    {
48
        $this->symfonyApplication->run();
49
    }
50
51 1
    public function getSymfonyApplication(): Application
52
    {
53 1
        return $this->symfonyApplication;
54
    }
55
}
56