Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | public function getHandlerForCommand($class) |
||
12 | { |
||
13 | $reflector = new ReflectionClass($class); |
||
14 | $dir = dirname($reflector->getFileName()); |
||
15 | |||
16 | $commandName = $reflector->getShortName(); |
||
17 | $handlerName = substr($commandName, 0, strrpos($commandName, 'Command')) . 'Handler'; |
||
18 | |||
19 | $path = $dir . DIRECTORY_SEPARATOR . $handlerName . '.php'; |
||
20 | if (!is_file($path)) { |
||
21 | throw new UnknownClassException('Class "' . $handlerName . '" was not found near to ' . $reflector->getName()); |
||
|
|||
22 | } |
||
23 | |||
24 | $className = $reflector->getNamespaceName() . '\\' . $handlerName; |
||
25 | return new $className(); |
||
26 | } |
||
27 | } |
||
28 |