| Conditions | 4 |
| Paths | 5 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | 7 | public function dispatch($command, array $args = []) |
|
| 33 | { |
||
| 34 | 7 | if (is_callable($command)) { |
|
| 35 | 2 | return call_user_func($command); |
|
| 36 | } |
||
| 37 | 5 | if (is_string($command)) { |
|
| 38 | 1 | $command = $this->container->get($command); |
|
| 39 | } |
||
| 40 | 5 | if (!method_exists($command, 'handle')) { |
|
| 41 | 1 | throw new \InvalidArgumentException('Command must be a callable or implement a handle method.'); |
|
| 42 | } |
||
| 43 | 4 | return $this->container->call([$command, 'handle'], $args); |
|
| 44 | } |
||
| 45 | } |
||
| 46 |