ListCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 38
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 4 1
A execute() 0 17 4
1
<?php
2
3
namespace Mathielen\ImportEngineBundle\Command;
4
5
use Mathielen\ImportEngine\Importer\ImporterRepository;
6
use Mathielen\ImportEngine\Validation\DummyValidation;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Helper\Table;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class ListCommand extends Command
13
{
14
15
    /**
16
     * @var ImporterRepository
17
     */
18
    private $importerRepository;
19
20
    public function __construct(ImporterRepository $importerRepository)
21
    {
22
        parent::__construct('importengine:list');
23
24
        $this->importerRepository = $importerRepository;
25
    }
26
27
    protected function configure()
28
    {
29
        $this->setDescription('Lists all available importer');
30
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $table = new Table($output);
35
        $table->setHeaders(['id', 'auto-detectable', 'validation']);
36
37
        foreach ($this->importerRepository->getIds() as $importerId) {
38
            $importer = $this->importerRepository->get($importerId);
39
40
            $table->addRow([
41
                $importerId,
42
                $this->importerRepository->hasPrecondition($importerId) ? 'Yes' : 'No',
43
                ($importer->validation() instanceof DummyValidation) ? 'No' : 'Yes',
44
            ]);
45
        }
46
47
        $table->render();
48
    }
49
}
50