ListCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
cbo 5
dl 0
loc 56
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 17 1
B doExecute() 0 29 4
1
<?php
2
3
/**
4
 * This file is part of Bldr.io
5
 *
6
 * (c) Aaron Scherer <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE
10
 */
11
12
namespace Bldr\Block\Core\Command\Task;
13
14
use Bldr\Block\Core\Task\AbstractTask;
15
use Bldr\Command\AbstractCommand;
16
use Symfony\Component\Console\Helper\Table;
17
use Symfony\Component\Console\Helper\TableStyle;
18
19
/**
20
 * @author Aaron Scherer <[email protected]>
21
 */
22
class ListCommand extends AbstractCommand
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    protected function configure()
28
    {
29
        $this->setName('task:list')
30
            ->setDescription("Lists all the available tasks for Bldr.")
31
            ->setHelp(
32
                <<<EOF
33
34
The <info>%command.name%</info> lists all the available tasks for Bldr.
35
36
To use:
37
38
    <info>$ bldr %command.name%</info>
39
40
EOF
41
            )
42
        ;
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48
    protected function doExecute()
49
    {
50
        $table = new Table($this->output);
51
        $table->setHeaders(['Name', 'Description']);
52
53
        $style = new TableStyle();
54
        $style->setCellHeaderFormat('<fg=red>%s</fg=red>');
55
        $style->setCellRowFormat('<fg=blue>%s</fg=blue>');
56
        $style->setBorderFormat('<fg=yellow>%s</fg=yellow>');
57
58
        $table->setStyle($style);
59
60
        /** @type AbstractTask[] $services */
61
        $services = $this->container->get('bldr.registry.task')->findAll();
62
        foreach ($services as $service) {
63
            if ($service instanceof AbstractTask) {
64
                $service->configure();
65
            }
66
67
            $table->addRow(
68
                [
69
                    $service->getName(),
70
                    $service->getDescription() !== '' ? $service->getDescription() : 'No Description'
71
                ]
72
            );
73
        }
74
75
        $table->render($this->output);
0 ignored issues
show
Unused Code introduced by
The call to Table::render() has too many arguments starting with $this->output.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
76
    }
77
}
78