Conditions | 4 |
Paths | 8 |
Total Lines | 18 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
15 | public function __invoke(Request $request, Response $response, $next) |
||
16 | { |
||
17 | $loadEnv = DatabaseConnection::loadEnv(); |
||
18 | $authHeader = $request->getHeader('token'); |
||
19 | try { |
||
20 | if (is_array($authHeader) && !empty($authHeader)) { |
||
21 | $jwtoken = $authHeader[0]; |
||
22 | $secretKey = base64_decode(getenv('secret')); |
||
23 | $jwt = json_decode($jwtoken, true); |
||
24 | //decode the JWT using the key from config |
||
25 | JWT::decode($jwt['jwt'], $secretKey, ['HS512']); |
||
26 | return $next($request, $response); |
||
27 | } |
||
28 | } catch (\Exception $e) { |
||
29 | return $response->withJson(['status' => $e->getMessage()], 401); |
||
30 | } |
||
31 | return $response->withJson(['status'], 401); |
||
32 | } |
||
33 | } |
||
34 |
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.