Passed
Push — master ( 37217b...efdda9 )
by Nico
19:16 queued 09:28
created

GenerateEmptySystemsCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 17
ccs 0
cts 13
cp 0
crap 2
rs 9.9332
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Cli;
6
7
use Ahc\Cli\Input\Command;
8
use Psr\Container\ContainerInterface;
9
use Stu\Component\StarSystem\GenerateEmptySystemsInterface;
10
11
/**
12
 * Provides cli method for generation of empty star systems
13
 */
14
final class GenerateEmptySystemsCommand extends Command
15
{
16
    private ContainerInterface $dic;
17
18
    public function __construct(
19
        ContainerInterface $dic
20
    ) {
21
        $this->dic = $dic;
22
23
        parent::__construct(
24
            'system:generate',
25
            'Generates empty systems'
26
        );
27
28
        $this
29
            ->argument(
30
                '<layerid>',
31
                'Id of the map layer'
32
            )
33
            ->usage(
34
                '<bold>  $0 system:generate 1</end> <comment></end> ## Generates star systems for the layer<eol/>'
35
            );
36
    }
37
38
    public function execute(int $layerid): void
39
    {
40
        $io = $this->io();
41
42
        $component = $this->dic->get(GenerateEmptySystemsInterface::class);
43
44
        $count = $component->generate($layerid);
45
46
        $io->ok(
47
            sprintf('Es wurden %d Systeme generiert.', $count),
48
            true
49
        );
50
    }
51
}
52