Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
18 | 7 | public static function build($diConsoleCommandClass) |
|
19 | { |
||
20 | 7 | if (is_string($diConsoleCommandClass) === false) { |
|
21 | 2 | throw new InvalidCommandException( |
|
22 | 2 | sprintf('Arg must be a string "%s" given', gettype($diConsoleCommandClass)) |
|
23 | 2 | ); |
|
24 | 5 | } elseif (class_exists($diConsoleCommandClass) === false) { |
|
25 | 1 | throw new InvalidCommandException( |
|
26 | 1 | sprintf('Class "%s" does not exist', $diConsoleCommandClass) |
|
27 | 1 | ); |
|
28 | 4 | } elseif (is_subclass_of($diConsoleCommandClass, '\SymfonyDiConsole\SymfonyDiConsoleInterface') === false) { |
|
29 | 1 | throw new InvalidCommandException( |
|
30 | 1 | sprintf( |
|
31 | 1 | 'Class "%s" must be instance of \SymfonyDiConsole\SymfonyDiConsoleInterface', |
|
32 | $diConsoleCommandClass |
||
33 | 1 | ) |
|
34 | 1 | ); |
|
35 | } |
||
36 | |||
37 | 3 | return new BaseCommand($diConsoleCommandClass); |
|
38 | } |
||
39 | } |
||
40 |