| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 5 | public function decorate(Message $message): Message |
|
| 18 | { |
||
| 19 | 5 | $event = $message->event(); |
|
| 20 | 5 | $id = $message->header(Header::AGGREGATE_ROOT_ID); |
|
| 21 | $headers = [ |
||
| 22 | 5 | Header::EVENT_TYPE => $this->inflector->instanceToType($event), |
|
| 23 | 5 | Header::TIME_OF_RECORDING => $event->timeOfRecording()->toString(), |
|
| 24 | ]; |
||
| 25 | |||
| 26 | 5 | if ($id instanceof AggregateRootId) { |
|
| 27 | 3 | $headers[Header::AGGREGATE_ROOT_ID] = $id->toString(); |
|
| 28 | 3 | $headers[Header::AGGREGATE_ROOT_ID_TYPE] = $this->inflector->instanceToType($id); |
|
| 29 | } |
||
| 30 | |||
| 31 | 5 | return $message->withHeaders($headers); |
|
| 32 | } |
||
| 33 | } |