Test Failed
Pull Request — master (#872)
by Maxim
08:22
created

Configurator::canConfigure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Console\Configurator;
6
7
use Spiral\Console\Command;
8
9
/**
10
 * @internal
11
 */
12
final class Configurator implements ConfiguratorInterface
13
{
14
    /**
15
     * @param ConfiguratorInterface[] $configurators
16
     */
17
    public function __construct(
18
        private readonly array $configurators = []
19
    ) {
20
    }
21
22
    public function configure(Command $command, \ReflectionClass $reflection): void
23
    {
24
        foreach ($this->configurators as $configurator) {
25
            if ($configurator->canConfigure($command, $reflection)) {
26
                $configurator->configure($command, $reflection);
27
                return;
28
            }
29
        }
30
31
        (new DefaultConfigurator())->configure($command, $reflection);
32
    }
33
34
    public function canConfigure(Command $command, \ReflectionClass $reflection): bool
35
    {
36
        return true;
37
    }
38
}
39