| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 34 | public function __invoke( |
|
| 15 | Request $request, |
||
| 16 | Response $response, |
||
| 17 | Route $next |
||
| 18 | ): ResponseInterface { |
||
| 19 | 34 | $jwtHeader = $request->getHeaderLine('Authorization'); |
|
| 20 | 34 | if (!$jwtHeader) { |
|
| 21 | 1 | throw new \App\Exception\AuthException('JWT Token required.', 400); |
|
| 22 | } |
||
| 23 | 33 | $jwt = explode('Bearer ', $jwtHeader); |
|
| 24 | 33 | if (!isset($jwt[1])) { |
|
| 25 | 1 | throw new \App\Exception\AuthException('JWT Token invalid.', 400); |
|
| 26 | } |
||
| 27 | 32 | $decoded = $this->checkToken($jwt[1]); |
|
| 28 | 31 | $object = (array) $request->getParsedBody(); |
|
| 29 | 31 | $object['decoded'] = $decoded; |
|
| 30 | |||
| 31 | 31 | return $next($request->withParsedBody($object), $response); |
|
| 32 | } |
||
| 34 |