Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ResponseDispatcher
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 triggerResponseCreated
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Common\Events;
3
4use Apie\Core\Context\ApieContext;
5use Psr\EventDispatcher\EventDispatcherInterface;
6use Psr\Http\Message\ResponseInterface;
7
8class 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}