| Conditions | 4 |
| Paths | 7 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 9 | ||
| Bugs | 6 | Features | 1 |
| 1 | <?php |
||
| 15 | public function __invoke(Request $request, Response $response, $next) |
||
| 16 | { |
||
| 17 | $loadEnv = DatabaseConnection::loadEnv(); |
||
| 18 | |||
| 19 | $authHeader = $request->getHeader('HTTP_AUTHORIZATION'); |
||
| 20 | |||
| 21 | try { |
||
| 22 | if (is_array($authHeader) && ! empty($authHeader)) { |
||
| 23 | $secretKey = base64_decode(getenv('secret')); |
||
| 24 | $jwt = json_decode($authHeader[0], true); |
||
| 25 | |||
| 26 | //decode the JWT using the key from config |
||
| 27 | $decodedToken = JWT::decode($jwt['jwt'], $secretKey, ['HS512']); |
||
| 28 | |||
| 29 | return $next($request, $response); |
||
| 30 | } |
||
| 31 | } catch (Exception $e) { |
||
| 32 | return $response->withJson(['message' => $e->getMessage()], 401); |
||
| 33 | } |
||
| 34 | |||
| 35 | return $response->withJson(['message' => 'User unauthorized due to invalid token'], 401); |
||
| 36 | } |
||
| 37 | } |
||
| 38 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.