Console::getHelp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/boot project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Boot\Console;
10
11
use Daikon\Config\ConfigProviderInterface;
12
use Symfony\Component\Console\Application;
13
use Symfony\Component\Console\Input\InputOption;
14
15
final class Console extends Application
16
{
17
    private ConfigProviderInterface $configProvider;
18
19
    public static function getLogo(): string
20
    {
21
        return <<<ASCII
22
   ____  ____  ____  _____ __  ______
23
  / __ \/ __ \/ __ \/ ___// / / /  _/
24
 / / / / /_/ / / / /\__ \/ /_/ // /
25
/ /_/ / _, _/ /_/ /___/ / __  // /
26
\____/_/ |_|\____//____/_/ /_/___/
27
28
ASCII;
29
    }
30
31
    public function __construct(
32
        ConfigProviderInterface $configProvider,
33
        array $consoleCommands = []
34
    ) {
35
        $this->configProvider = $configProvider;
36
37
        parent::__construct(
38
            (string)$configProvider->get('project.name'),
39
            sprintf('%s@%s', $configProvider->get('project.version'), $configProvider->get('app.env'))
40
        );
41
42
        $this->getDefinition()->addOption(
43
            new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The environment name.', 'dev')
44
        );
45
46
        foreach ($consoleCommands as $command) {
47
            $this->add($command);
48
        }
49
    }
50
51
    public function getHelp(): string
52
    {
53
        return self::getLogo().parent::getHelp();
54
    }
55
}
56