Completed
Pull Request — master (#448)
by
unknown
08:31
created

CliApplication   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace Phpmetrix;
4
5
use Ahc\Cli\Application;
6
use Phpmetrix\Console\Command\AnalyzeCommand;
7
use Psr\Container\ContainerExceptionInterface;
8
use Psr\Container\ContainerInterface;
9
10
final class CliApplication
11
{
12
    public const APP_NAME = 'Phpmetrix';
13
    public const APP_VERSION = '0.1';
14
15
    private $dic;
16
17
    private $cli;
18
19
    public function __construct(ContainerInterface $dic, ExitInterface $exit)
20
    {
21
        $this->dic = $dic;
22
        $this->cli = new Application(self::APP_NAME, self::APP_VERSION, [$exit, 'onExit']);
23
    }
24
25
    /**
26
     * @param string[] $argv
27
     *
28
     * @throws ContainerExceptionInterface
29
     */
30
    public function handle(array $argv) : void
31
    {
32
        $this->cli->add($this->dic->get(AnalyzeCommand::class));
33
        $this->cli->handle($argv);
34
    }
35
}
36