Conditions | 1 |
Paths | 1 |
Total Lines | 12 |
Code Lines | 3 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | 1 | public function execute(object $command, callable $next) |
|
35 | { |
||
36 | // 1. Based on the command we received, get the Handler method to call. |
||
37 | 1 | $methodToCall = $this->mapping->mapCommandToHandler(get_class($command)); |
|
38 | |||
39 | // 2. Retrieve an instance of the Handler from our PSR-11 container |
||
40 | // This assumes the container id is the same as the class name but |
||
41 | // you can write your own middleware to change this assumption! :) |
||
42 | 1 | $handler = $this->container->get($methodToCall->getClassName()); |
|
43 | |||
44 | // 3. Invoke the correct method on the handler and pass the command |
||
45 | 1 | return $handler->{$methodToCall->getMethodName()}($command); |
|
46 | } |
||
48 |