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

Configurator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A configure() 0 10 3
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