Configurator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A doAccept() 0 4 1
A doConfigure() 0 10 2
1
<?php
2
/**
3
 * This file is part of the phpspec-console package.
4
 * (c) 2017 Timo Michna <timomichna/yahoo.de>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Tidal\PhpSpec\ConsoleExtension\Command;
11
12
use Tidal\PhpSpec\ConsoleExtension\Behavior\Command\ConfiguratorTrait;
13
use Tidal\PhpSpec\ConsoleExtension\Contract\Command\{
14
    CommandInterface,
15
    ConfiguratorInterface
16
};
17
use RuntimeException;
18
19
/**
20
 * class Tidal\PhpSpec\ConsoleExtension\\Configurator
21
 */
22
class Configurator implements ConfiguratorInterface
23
{
24
    use ConfiguratorTrait;
25
26
    /**
27
     * @param CommandInterface $command
28
     * @return bool
29
     */
30
    protected function doAccept(CommandInterface $command): bool
31
    {
32
        return $command instanceof CommandInterface;
33
    }
34
35
    /**
36
     * @param CommandInterface $command
37
     */
38
    protected function doConfigure(CommandInterface $command)
39
    {
40
       if (!isset($this->config)) {
41
            throw new RuntimeException(sprintf(
42
                "Cannot run command '%s'. Config has not been set in &s",
43
                $command->getName(),
44
                __METHOD__
45
            ));
46
       }
47
    }
48
}
49
50