SearchCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A runFromCommands() 0 27 3
1
<?php
2
3
namespace Startwind\Forrest\CliCommand\Search;
4
5
use Startwind\Forrest\CliCommand\RunCommand;
6
use Startwind\Forrest\Output\OutputHelper;
7
use Symfony\Component\Console\Command\Command as SymfonyCommand;
8
9
abstract class SearchCommand extends RunCommand
10
{
11
    /**
12
     * Choose from a list of commands and execute one.
13
     */
14
    protected function runFromCommands(array $commands, $values = [], bool $addAiOption = false): int|bool
15
    {
16
        /** @var \Symfony\Component\Console\Helper\QuestionHelper $questionHelper */
17
        $questionHelper = $this->getHelper('question');
18
19
        $command = OutputHelper::renderCommands(
20
            $this->getOutput(),
21
            $this->getInput(),
22
            $questionHelper,
23
            $commands,
24
            null,
25
            -1,
26
            true,
27
            $addAiOption
28
        );
29
30
        if ($command === false) {
0 ignored issues
show
introduced by
The condition $command === false is always false.
Loading history...
31
            return SymfonyCommand::FAILURE;
32
        }
33
34
        if ($command === true) {
0 ignored issues
show
introduced by
The condition $command === true is always false.
Loading history...
35
            return true;
36
        }
37
38
        $this->getOutput()->writeln('');
39
40
        return $this->runCommand($command, $values);
41
    }
42
}
43