| Conditions | 3 |
| Paths | 6 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 13 | ||
| Bugs | 1 | Features | 2 |
| 1 | <?php |
||
| 23 | public function __invoke($request, $response, $next) |
||
| 24 | { |
||
| 25 | $authHeader = $request->getHeader('HTTP_AUTHORIZATION'); |
||
| 26 | |||
| 27 | try { |
||
| 28 | if (!empty($authHeader)) { |
||
| 29 | $appSecret = getenv('APP_SECRET'); |
||
| 30 | $jwt = $authHeader[0]; |
||
| 31 | $decodedToken = JWT::decode($jwt, $appSecret, ['HS512']); |
||
|
|
|||
| 32 | |||
| 33 | return $next($request, $response); |
||
| 34 | } |
||
| 35 | |||
| 36 | } catch (Exception $e) { |
||
| 37 | return $response->withJson(['message' => 'Token invalid or expired'], 500); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $response->withJson(['message' => 'User unauthorized due to empty token'], 401); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.