Conditions | 5 |
Paths | 4 |
Total Lines | 31 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function dispatch(Route $route, ConsoleAdapter $console) |
||
19 | { |
||
20 | $name = $route->getName(); |
||
|
|||
21 | if (! isset($this->commandMap[$name])) { |
||
22 | $console->writeLine(''); |
||
23 | $console->writeLine(sprintf('Unhandled command "%s" invoked', $name), Color::WHITE, Color::RED); |
||
24 | $console->writeLine(''); |
||
25 | $console->writeLine('The command does not have a registered handler.'); |
||
26 | return 1; |
||
27 | } |
||
28 | |||
29 | $callable = $this->commandMap[$name]; |
||
30 | |||
31 | if (! is_callable($callable) && is_string($callable)) { |
||
32 | $callable = new $callable(); |
||
33 | if (! is_callable($callable)) { |
||
34 | throw new RuntimeException(sprintf( |
||
35 | 'Invalid command class specified for "%s"; class must be invokable', |
||
36 | $name |
||
37 | )); |
||
38 | } |
||
39 | $this->commandMap[$name] = $callable; |
||
40 | } |
||
41 | $return = $this->container->call($callable, [ |
||
42 | $route, |
||
43 | $console, |
||
44 | $this->container |
||
45 | ]); |
||
46 | |||
47 | return (int) $return; |
||
48 | } |
||
49 | } |
||
50 |