Test Failed
Push — master ( ec8ff1...24c3c9 )
by Vladimir
05:33
created

GroupInfoCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 13
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the `tvi/monitor-bundle` project.
5
 *
6
 * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
11
12
namespace Tvi\MonitorBundle\Command;
13
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Input\InputOption;
17
use Symfony\Component\Console\Output\OutputInterface;
18
use Tvi\MonitorBundle\Runner\Manager;
19
20
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
 * @author Vladimir Turnaev <[email protected]>
22
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
23
class GroupInfoCommand extends Command
24
{
25
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
26
     * @var Manager
27
     */
28
    private $manager;
0 ignored issues
show
Coding Style introduced by
Private member variable "manager" must be prefixed with an underscore
Loading history...
29
30
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
31
     * @param Manager $manager
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
32
     * @param null    $name
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $name is correct as it would always require null to be passed?
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
33
     */
34
    public function __construct(Manager $manager, string $name = null)
35
    {
36
        parent::__construct($name);
37
        $this->manager = $manager;
38
    }
39
40
    protected function configure()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function configure()
Loading history...
41
    {
42
        $this
43
            ->setName('tvi:monitor:group:info')
44
            ->setDescription('Info Groups')
45
            ->addOption(
46
                'groups',
47
                'g',
48
                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
49
                'Groups filter'
50
            )
51
            ->setHelp(
52
                <<<EOT
53
The <info>%command.name%</info> get check info
54
55
* Info Groups:
56
57
  <info>php %command.full_name% [--groups=... ,] </info>
58
59
EOT
60
            );
61
    }
62
63
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
64
     * @param InputInterface  $input
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
65
     * @param OutputInterface $output
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
66
     *
67
     * @return int|null|void
68
     */
69
    protected function execute(InputInterface $input, OutputInterface $output)
70
    {
71
        $groupsFilter = $input->getOption('groups');
72
        $groupsFilter = ($groupsFilter) ? $groupsFilter : null;
73
74
        $manager = $this->manager;
75
        $groups = $manager->findGroups($groupsFilter);
0 ignored issues
show
Bug introduced by
It seems like $groupsFilter can also be of type true; however, parameter $groups of Tvi\MonitorBundle\Runner\Manager::findGroups() does only seem to accept null|string|string[], maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

75
        $groups = $manager->findGroups(/** @scrutinizer ignore-type */ $groupsFilter);
Loading history...
76
77
        foreach ($groups as $tag) {
78
            $output->writeln(sprintf('<fg=yellow;options=bold>%s</>', $tag->getLabel()));
79
            foreach ($tag as $check) {
80
                $output->writeln(sprintf('<info>%-40s</info> %s', $check->getId(), $check->getLabel()));
81
            }
82
            $output->writeln('');
83
        }
84
    }
85
}
86