BuildDocCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 31
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 3 1
A isHidden() 0 3 1
A execute() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace Cocotte\Command;
4
5
use Cocotte\Console\Documentation\MarkdownDocumentation;
6
use Cocotte\Environment\EnvironmentState;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
final class BuildDocCommand extends Command
12
{
13
    /**
14
     * @var EnvironmentState
15
     */
16
    private $environmentState;
17
18
    public function __construct(EnvironmentState $environmentState)
19
    {
20
        $this->environmentState = $environmentState;
21
        parent::__construct();
22
    }
23
24
    public function isHidden()
25
    {
26
        return true;
27
    }
28
29
    protected function configure(): void
30
    {
31
        $this->setName('build-doc');
32
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        if (!$this->environmentState->isBare()) {
37
            throw new \Exception("Environment is populated. This command needs to run on a bare environment.");
38
        }
39
40
        $markdownDocumentation = new MarkdownDocumentation($output);
41
        $markdownDocumentation->document($this->getApplication());
42
    }
43
44
}
45