Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ResponseDispatcher | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| triggerResponseCreated | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Common\Events; |
| 3 | |
| 4 | use Apie\Core\Context\ApieContext; |
| 5 | use Psr\EventDispatcher\EventDispatcherInterface; |
| 6 | use Psr\Http\Message\ResponseInterface; |
| 7 | |
| 8 | class ResponseDispatcher |
| 9 | { |
| 10 | public function __construct(private readonly EventDispatcherInterface $dispatcher) |
| 11 | { |
| 12 | } |
| 13 | |
| 14 | public function triggerResponseCreated(ResponseInterface $response, ApieContext $context): ResponseInterface |
| 15 | { |
| 16 | $event = new ApieResponseCreated($response, $context); |
| 17 | $this->dispatcher->dispatch($event); |
| 18 | return $event->response; |
| 19 | } |
| 20 | } |