| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | 3 | public function onKernelResponse(ResponseEvent $event) |
|
| 32 | { |
||
| 33 | 3 | if (false === $this->header['display']) { |
|
| 34 | 1 | return; |
|
| 35 | } |
||
| 36 | |||
| 37 | 2 | $request = $event->getRequest(); |
|
| 38 | 2 | $rateLimitInfo = $request->attributes->get('_api_rate_limit_info', null); |
|
| 39 | 2 | if (null === $rateLimitInfo) { |
|
| 40 | 1 | return; |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | $response = $event->getResponse(); |
|
| 44 | 1 | $response->headers->set($this->header['names']['limit'], $rateLimitInfo['limit'] ?? 0); |
|
| 45 | 1 | $response->headers->set($this->header['names']['remaining'], $rateLimitInfo['remaining'] ?? 0); |
|
| 46 | 1 | $response->headers->set($this->header['names']['reset'], $rateLimitInfo['reset'] ?? 0); |
|
| 47 | 1 | } |
|
| 49 |