| Total Complexity | 5 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class ResponseListener extends MediaTypeListener |
||
| 11 | { |
||
| 12 | private static $noContentMethods = [ |
||
| 13 | 'HEAD', |
||
| 14 | ]; |
||
| 15 | |||
| 16 | 3 | public function onKernelView(GetResponseForControllerResultEvent $event): void |
|
| 35 | ) |
||
| 36 | ); |
||
| 37 | 2 | } |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Checks if the response should contain any content. |
||
| 41 | * |
||
| 42 | * @param string $method |
||
| 43 | * |
||
| 44 | * @return bool |
||
| 45 | */ |
||
| 46 | 2 | private function isContentAllowed(string $method): bool |
|
| 47 | { |
||
| 48 | 2 | return !in_array($method, self::$noContentMethods); |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Create a response for the given data. |
||
| 53 | * |
||
| 54 | * @param string $body |
||
| 55 | * @param int $status |
||
| 56 | * @param string $contentType |
||
| 57 | * |
||
| 58 | * @return Response |
||
| 59 | */ |
||
| 60 | 2 | private function createResponse(string $body, int $status, string $contentType): Response |
|
| 66 | ); |
||
| 67 | } |
||
| 69 |