| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | public function __invoke(Request $request, Response $response, callable $next = null) |
||
| 49 | { |
||
| 50 | /** |
||
| 51 | * Check if user is logged in. |
||
| 52 | */ |
||
| 53 | $user = $this->session->getStorage()->user; |
||
|
|
|||
| 54 | if (!$user) { |
||
| 55 | return $response->withStatus(302)->withHeader( |
||
| 56 | 'Location', |
||
| 57 | $this->router->generateUri('auth', ['action' => 'login']) |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | /* |
||
| 62 | * If everything is OK, continue execution middleware |
||
| 63 | */ |
||
| 64 | return $next($request, $response); |
||
| 65 | } |
||
| 66 | } |
||
| 67 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: