| Total Complexity | 3 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | final class StatusCodeMiddleware implements MiddlewareInterface |
||
| 28 | { |
||
| 29 | /** |
||
| 30 | * @var int |
||
| 31 | */ |
||
| 32 | private $statusCode; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * StatusCodeMiddleware constructor. |
||
| 36 | * |
||
| 37 | * @param int $statusCode |
||
| 38 | * |
||
| 39 | * @throws \ReflectionException |
||
| 40 | */ |
||
| 41 | public function __construct(int $statusCode) |
||
| 42 | { |
||
| 43 | $reflection = new \ReflectionClass(StatusCodeInterface::class); |
||
| 44 | $allowedStatus = $reflection->getConstants(); |
||
| 45 | |||
| 46 | if (!\in_array($statusCode, $allowedStatus)) { |
||
| 47 | throw new \UnexpectedValueException('Invalid HTTP Status Code'); |
||
| 48 | } |
||
| 49 | |||
| 50 | $this->statusCode = $statusCode; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * {@inheritdoc} |
||
| 55 | */ |
||
| 56 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 59 | } |
||
| 60 | } |
||
| 61 |