SearchCommand::runFromCommands()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 27
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 15
c 0
b 0
f 0
nc 3
nop 3
dl 0
loc 27
rs 9.7666
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