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

ConstantBasedConfigurator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 3
A canConfigure() 0 3 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 ConstantBasedConfigurator implements ConfiguratorInterface
13
{
14
    public function configure(Command $command, \ReflectionClass $reflection): void
15
    {
16
        $command->setName($reflection->getConstant('NAME'));
17
        $command->setDescription((string) $reflection->getConstant('DESCRIPTION'));
18
19
        foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) {
20
            \call_user_func_array([$command, 'addOption'], $option);
21
        }
22
23
        foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) {
24
            \call_user_func_array([$command, 'addArgument'], $argument);
25
        }
26
    }
27
28
    public function canConfigure(Command $command, \ReflectionClass $reflection): bool
29
    {
30
        return true;
31
    }
32
}
33