ListCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
c 2
b 0
f 0
dl 0
loc 25
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A doExecute() 0 20 3
1
<?php
2
3
namespace Startwind\Forrest\CliCommand\Repository;
4
5
use Startwind\Forrest\Output\OutputHelper;
6
use Startwind\Forrest\Repository\EditableRepository;
7
use Symfony\Component\Console\Command\Command as SymfonyCommand;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class ListCommand extends RepositoryCommand
12
{
13
    protected static $defaultName = 'repository:list';
14
    protected static $defaultDescription = 'List all registered command repositories.';
15
16
    protected function doExecute(InputInterface $input, OutputInterface $output): int
17
    {
18
        $this->enrichRepositories();
19
20
        $rows = [];
21
22
        foreach ($this->getRepositoryCollection()->getRepositories() as $identifier => $repository) {
23
            $rows[] = [
24
                $identifier,
25
                $repository->getName(),
26
                $repository->getDescription(),
27
                $repository instanceof EditableRepository ? 'x' : '',
28
            ];
29
        }
30
31
        $headlines = ['Identifier', 'Name', 'Description', 'Writable'];
32
33
        OutputHelper::renderTable($output, $headlines, $rows);
34
35
        return SymfonyCommand::SUCCESS;
36
    }
37
}
38