turnaev /
monitor-bundle
| 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
Loading history...
|
|||
| 11 | |||
| 12 | namespace Tvi\MonitorBundle\Command; |
||
| 13 | |||
| 14 | use Symfony\Component\Console\Command\Command; |
||
| 15 | use Symfony\Component\Console\Helper\TableCell; |
||
| 16 | use Symfony\Component\Console\Helper\TableSeparator; |
||
| 17 | use Symfony\Component\Console\Input\InputInterface; |
||
| 18 | use Symfony\Component\Console\Input\InputOption; |
||
| 19 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 20 | use Symfony\Component\Console\Helper\Table; |
||
| 21 | use Tvi\MonitorBundle\Reporter\Console; |
||
| 22 | use Tvi\MonitorBundle\Runner\RunnerManager; |
||
| 23 | |||
| 24 | /** |
||
|
0 ignored issues
–
show
|
|||
| 25 | * @author Vladimir Turnaev <[email protected]> |
||
| 26 | */ |
||
|
0 ignored issues
–
show
|
|||
| 27 | class CheckInfoCommand extends Command |
||
| 28 | { |
||
| 29 | /** |
||
|
0 ignored issues
–
show
|
|||
| 30 | * @var Manager |
||
|
0 ignored issues
–
show
The type
Tvi\MonitorBundle\Command\Manager was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 31 | */ |
||
| 32 | private $runnerManager; |
||
|
0 ignored issues
–
show
|
|||
| 33 | |||
| 34 | /** |
||
|
0 ignored issues
–
show
|
|||
| 35 | * @param ?string $name |
||
|
0 ignored issues
–
show
|
|||
| 36 | */ |
||
| 37 | public function __construct(RunnerManager $runnerManager, string $name = null) |
||
| 38 | { |
||
| 39 | parent::__construct($name); |
||
| 40 | $this->runnerManager = $runnerManager; |
||
|
0 ignored issues
–
show
It seems like
$runnerManager of type Tvi\MonitorBundle\Runner\RunnerManager is incompatible with the declared type Tvi\MonitorBundle\Command\Manager of property $runnerManager.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 41 | } |
||
| 42 | |||
| 43 | protected function configure() |
||
|
0 ignored issues
–
show
|
|||
| 44 | { |
||
| 45 | $this |
||
| 46 | ->setName( |
||
| 47 | 'tvi:monitor:check:info' |
||
| 48 | ) |
||
| 49 | ->setDescription( |
||
| 50 | 'Info health checks' |
||
| 51 | ) |
||
| 52 | ->addOption( |
||
| 53 | 'check', |
||
| 54 | 'c', |
||
| 55 | InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
||
| 56 | 'Check filter' |
||
| 57 | ) |
||
| 58 | ->addOption( |
||
| 59 | 'group', |
||
| 60 | 'g', |
||
| 61 | InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
||
| 62 | 'Groups filter' |
||
| 63 | ) |
||
| 64 | ->addOption( |
||
| 65 | 'tag', |
||
| 66 | 't', |
||
| 67 | InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
||
| 68 | 'Tag(s) filter' |
||
| 69 | ) |
||
| 70 | ->setHelp( |
||
| 71 | <<<'EOT' |
||
| 72 | The <info>%command.name%</info> get check info |
||
| 73 | |||
| 74 | * INfo Checks: |
||
| 75 | |||
| 76 | <info>php %command.full_name% [--check=... ,] [--group=... ,] [--tag==... ,] </info> |
||
| 77 | |||
| 78 | EOT |
||
| 79 | ); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
|
0 ignored issues
–
show
|
|||
| 83 | * @return int|null|void |
||
| 84 | */ |
||
| 85 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 86 | { |
||
| 87 | $checkFilter = $input->getOption('check'); |
||
| 88 | $groupFilter = $input->getOption('group'); |
||
| 89 | $tagFilter = $input->getOption('tag'); |
||
| 90 | |||
| 91 | $checks = $this->runnerManager->findChecksSorted($checkFilter, $groupFilter, $tagFilter); |
||
| 92 | |||
| 93 | $table = new Table($output); |
||
| 94 | $table->setHeaders(['Check', 'Tag(s)', 'Label']); |
||
| 95 | |||
| 96 | $groupOld = null; |
||
| 97 | foreach ($checks as $check) { |
||
| 98 | $tags = $check->getTags(); |
||
| 99 | |||
| 100 | if ($tags) { |
||
| 101 | $tags = $this->runnerManager->findTags($check->getTags()); |
||
| 102 | $tags = array_map(static function ($t) { |
||
|
0 ignored issues
–
show
|
|||
| 103 | return $t->getLabel(); |
||
| 104 | }, $tags); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 105 | |||
| 106 | $tags = implode(', ', $tags); |
||
| 107 | } else { |
||
| 108 | $tags = null; |
||
| 109 | } |
||
| 110 | |||
| 111 | $group = null; |
||
| 112 | $groupNew = sprintf('<fg=default;options=bold>%s</>', $check->getGroup()); |
||
| 113 | |||
| 114 | if ($groupOld !== $groupNew) { |
||
| 115 | if ($groupOld) { |
||
| 116 | $table->addRow(new TableSeparator()); |
||
| 117 | } |
||
| 118 | $table->addRow([new TableCell($groupNew, ['colspan' => 3])]); |
||
| 119 | $table->addRow(new TableSeparator()); |
||
| 120 | |||
| 121 | $group = $groupOld = $groupNew; |
||
|
0 ignored issues
–
show
|
|||
| 122 | } |
||
| 123 | |||
| 124 | $importanceTag = Console::tagByImportance($check->getImportance()); |
||
| 125 | $id = sprintf('%s%s</>', $importanceTag, $check->getId()); |
||
| 126 | $table->addRow([$id, $tags, $check->getLabel()]); |
||
| 127 | } |
||
| 128 | |||
| 129 | $table->render(); |
||
| 130 | } |
||
| 131 | } |
||
| 132 |