Test Failed
Pull Request — master (#872)
by Maxim
10:54 queued 03:52
created

Configurator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
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 ConstantBasedConfigurator())->configure($command, $reflection);
32
    }
33
}
34