Application   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 20
c 0
b 0
f 0
dl 0
loc 39
ccs 21
cts 21
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerConsole() 0 6 1
A __construct() 0 25 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Thunder micro CLI framework.
7
 * (c) Jérémy Marodon <[email protected]>
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace RxThunder\Core;
13
14
use RxThunder\Core\Kernel\KernelInterface;
15
use Silly\Application as BaseApplication;
16
use Silly\Input\InputOption;
17
18
class Application extends BaseApplication
19
{
20 1
    public function __construct(KernelInterface $kernel)
21
    {
22 1
        $kernel_class = \get_class($kernel);
23 1
        $kernel->boot();
24
25 1
        parent::__construct($kernel_class::NAME, $kernel_class::VERSION);
26
27 1
        $container = $kernel->getContainer();
28 1
        $this->useContainer($container);
29
30 1
        $this->getDefinition()->addOptions([
31 1
            new InputOption(
32 1
                '--env',
33 1
                '-e',
34 1
                InputOption::VALUE_OPTIONAL,
35 1
                'The environment name',
36 1
                $kernel->getEnvironment()
37
            ),
38
        ]);
39
40
        /** @psalm-var array<class-string, array<string, string>> $console_services_list */
41 1
        $console_services_list = $container->findTaggedServiceIds('console');
42
43 1
        foreach ($console_services_list as $id => $tag) {
44 1
            $this->registerConsole($id);
45
        }
46 1
    }
47
48
    /**
49
     * @param class-string $console_class
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
50
     */
51 1
    private function registerConsole(string $console_class): void
52
    {
53
        $this
54 1
            ->command($console_class::$expression, $console_class)
0 ignored issues
show
Bug introduced by
The property expression does not exist on string.
Loading history...
55 1
            ->descriptions($console_class::$description, $console_class::$arguments_and_options)
0 ignored issues
show
Bug introduced by
The property arguments_and_options does not exist on string.
Loading history...
Bug introduced by
The property description does not exist on string.
Loading history...
56 1
            ->defaults($console_class::$defaults);
0 ignored issues
show
Bug introduced by
The property defaults does not exist on string.
Loading history...
57 1
    }
58
}
59