1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace EventSauce\EventSourcing; |
||
6 | |||
7 | class MessageDispatchingEventDispatcher implements EventDispatcher |
||
8 | { |
||
9 | /** |
||
10 | * @var MessageDispatcher |
||
11 | */ |
||
12 | private $dispatcher; |
||
13 | |||
14 | /** |
||
15 | * @var MessageDecorator|null |
||
16 | */ |
||
17 | private $decorator; |
||
18 | |||
19 | 2 | public function __construct(MessageDispatcher $dispatcher, ?MessageDecorator $decorator = null) |
|
20 | { |
||
21 | 2 | $this->dispatcher = $dispatcher; |
|
22 | 2 | $this->decorator = $decorator ?: new DefaultHeadersDecorator(); |
|
23 | 2 | } |
|
24 | |||
25 | 1 | public function dispatch(object ...$events): void |
|
26 | { |
||
27 | 1 | $this->dispatchWithHeaders([], ...$events); |
|
28 | 1 | } |
|
29 | |||
30 | 2 | public function dispatchWithHeaders(array $headers, object ...$events): void |
|
31 | { |
||
32 | 2 | $messages = []; |
|
33 | |||
34 | 2 | foreach ($events as $event) { |
|
35 | 2 | $messages[] = $this->decorator->decorate(new Message($event, $headers)); |
|
0 ignored issues
–
show
|
|||
36 | } |
||
37 | |||
38 | 2 | $this->dispatcher->dispatch(...$messages); |
|
39 | 2 | } |
|
40 | } |
||
41 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.