ListFieldCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 1
b 0
f 0
dl 0
loc 28
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 7 2
A __construct() 0 6 1
A configure() 0 5 1
1
<?php
2
3
/*
4
 * This file is part of the SexyField package.
5
 *
6
 * (c) Dion Snoeijen <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare (strict_types = 1);
13
14
namespace Tardigrades\Command;
15
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
use Tardigrades\SectionField\Service\FieldManagerInterface;
19
use Tardigrades\SectionField\Service\FieldNotFoundException;
20
21
class ListFieldCommand extends FieldCommand
22
{
23
    /** @var FieldManagerInterface */
24
    private $fieldManager;
25
26
    public function __construct(
27
        FieldManagerInterface $fieldManager
28
    ) {
29
        $this->fieldManager = $fieldManager;
30
31
        parent::__construct('sf:list-field');
32
    }
33
34
    protected function configure()
35
    {
36
        $this
37
            ->setDescription('Show installed fields.')
38
            ->setHelp('This command lists all installed fields.')
39
        ;
40
    }
41
42
    protected function execute(InputInterface $input, OutputInterface $output)
43
    {
44
        try {
45
            $fields = $this->fieldManager->readAll();
46
            $this->renderTable($output, $fields, 'All installed Fields');
47
        } catch (FieldNotFoundException $exception) {
48
            $output->writeln('No fields found');
49
        }
50
    }
51
}
52