Application   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
eloc 12
dl 0
loc 54
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCommandName() 0 3 1
A setHome() 0 3 1
A getDefinition() 0 6 1
A getDefaultCommands() 0 5 1
A getHome() 0 7 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fabiang\ExceptionGenerator\Cli\Console;
6
7
use Fabiang\ExceptionGenerator\Cli\Command\ExceptionGeneratorCommand;
8
use Symfony\Component\Console\Application as ConsoleApplication;
9
use Symfony\Component\Console\Input\InputDefinition;
10
use Symfony\Component\Console\Input\InputInterface;
11
12
use function getenv;
13
14
class Application extends ConsoleApplication
15
{
16
    /**
17
     * Home directory.
18
     */
19
    protected ?string $home = null;
20
21
    /**
22
     * {@inheritDoc}
23
     */
24
    protected function getCommandName(InputInterface $input): string
25
    {
26
        return 'exception-generator';
27
    }
28
29
    /**
30
     * {@inheritDoc}
31
     */
32
    protected function getDefaultCommands(): array
33
    {
34
        $commands   = parent::getDefaultCommands();
35
        $commands[] = new ExceptionGeneratorCommand();
36
        return $commands;
37
    }
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public function getDefinition(): InputDefinition
43
    {
44
        $inputDefinition = parent::getDefinition();
45
        // clear out the normal first argument, which is the command name
46
        $inputDefinition->setArguments();
47
        return $inputDefinition;
48
    }
49
50
    /**
51
     * Get path to home directory.
52
     */
53
    public function getHome(): ?string
54
    {
55
        if (null === $this->home) {
56
            $this->home = getenv('HOME') ?: null;
57
        }
58
59
        return $this->home;
60
    }
61
62
    /**
63
     * Set path to home directory.
64
     */
65
    public function setHome(string $home): void
66
    {
67
        $this->home = $home;
68
    }
69
}
70