1 | <?php |
||
22 | class Bus implements CommandBusInterface |
||
23 | { |
||
24 | |||
25 | /** @var CommandBus */ |
||
26 | protected $bus; |
||
27 | |||
28 | /** @var CommandNameExtractor */ |
||
29 | protected $commandNameExtractor; |
||
30 | |||
31 | /** @var MethodNameInflector */ |
||
32 | protected $methodNameInflector; |
||
33 | |||
34 | /** @var LocatorInterface */ |
||
35 | protected $handlerLocator; |
||
36 | |||
37 | public function __construct( |
||
46 | |||
47 | /** |
||
48 | * Dispatch a command |
||
49 | * |
||
50 | 7 | * @param object $command Command to be dispatched |
|
51 | 7 | * @param array $input Array of input to map to the command |
|
52 | 7 | * @param array $middleware Array of middleware class name to add to the stack, they are resolved from the laravel container |
|
53 | 7 | * @return mixed |
|
54 | */ |
||
55 | public function dispatch($command, array $input = [], array $middleware = []) |
||
61 | |||
62 | private function bindCommandWitHisCommandHandler($command) |
||
72 | |||
73 | /** |
||
74 | * @param $command |
||
75 | 7 | * @return string |
|
76 | */ |
||
77 | 7 | private function getNameOfClass($command): string |
|
87 | |||
88 | 7 | /** |
|
89 | * Add the Command Handler |
||
90 | 7 | * |
|
91 | 7 | * @param string $command Class name of the command |
|
92 | 7 | * @param string $handler Class name of the handler to be resolved from the Laravel Container |
|
93 | 7 | * @return mixed |
|
94 | 7 | */ |
|
95 | public function addHandler($command, $handler) |
||
99 | |||
100 | /** |
||
101 | * Handle the command |
||
102 | * |
||
103 | * @param $command |
||
104 | * @param $input |
||
105 | * @param $middleware |
||
106 | 7 | * @return mixed |
|
107 | */ |
||
108 | 7 | protected function handleTheCommand($command, $input, array $middleware) |
|
119 | |||
120 | /** |
||
121 | * Resolve the middleware stack from the laravel container |
||
122 | * |
||
123 | 7 | * @param $middleware |
|
124 | * @return array |
||
125 | 7 | */ |
|
126 | 1 | protected function resolveMiddleware(array $middleware) |
|
135 | 2 | ||
136 | /** |
||
137 | * Map the input to the command |
||
138 | 4 | * |
|
139 | 4 | * @param $command |
|
140 | 1 | * @param $input |
|
141 | * @return object |
||
142 | 6 | */ |
|
143 | protected function mapInputToCommand($command, $input) |
||
169 | |||
170 | /** |
||
171 | * Returns Default Value for parameter if it exists Or Fail |
||
172 | * |
||
173 | * @ReflectionParameter $parameter |
||
174 | * @return mixed |
||
175 | */ |
||
176 | private function getDefaultValueOrFail($parameter) |
||
184 | |||
185 | } |
||
186 |