Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
4 / 4 |
|
66.67% |
2 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| EventBus | |
100.00% |
2 / 2 |
|
100.00% |
4 / 4 |
|
66.67% |
2 / 3 |
|
100.00% |
1 / 1 |
2.15 | |
100.00% |
1 / 1 |
| dispatch | n/a |
0 / 0 |
n/a |
0 / 0 |
n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||||
| dispatchAll | |
100.00% |
2 / 2 |
|
100.00% |
4 / 4 |
|
66.67% |
2 / 3 |
|
100.00% |
1 / 1 |
2.15 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Shared\Domain\Port\Driven; |
| 4 | |
| 5 | use App\Shared\Domain\Event\DomainEvent; |
| 6 | use App\Shared\Domain\Model\ProducesDomainEvents; |
| 7 | |
| 8 | /** |
| 9 | * @author W.Zwertvaegher |
| 10 | * Domain Event Bus interface (i.e. Port) |
| 11 | * This MUST be implemented by the infra to allow sending events from handlers on entities operations |
| 12 | */ |
| 13 | |
| 14 | abstract class EventBus |
| 15 | { |
| 16 | abstract public function dispatch(DomainEvent $event): void; |
| 17 | |
| 18 | /** |
| 19 | * @param ProducesDomainEvents $aggregate |
| 20 | * @return void |
| 21 | */ |
| 22 | public function dispatchAll(ProducesDomainEvents $aggregate): void |
| 23 | { |
| 24 | foreach ($aggregate->pullEvents() as $event) { |
| 25 | $this->dispatch($event); |
| 26 | } |
| 27 | } |
| 28 | } |