Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4.0119 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
25 | 2 | public function user() |
|
26 | { |
||
27 | 2 | if (! is_null($this->user)) { |
|
28 | return $this->user; |
||
29 | } |
||
30 | |||
31 | 2 | $session = $this->session->retrieve(); |
|
32 | |||
33 | // Laravel implements a Chain of Responsibility on the Authentication process. |
||
34 | // If this Guard cannot authenticate, we must return null to give room for |
||
35 | // other Guards to attempt to authenticate the current request. |
||
36 | 2 | if (! $session) { |
|
|
|||
37 | 1 | return null; |
|
38 | } |
||
39 | |||
40 | 1 | $user = $this->provider->retrieveByCredentials($session); |
|
41 | |||
42 | 1 | if ($user) { |
|
43 | 1 | $this->dispatcher->dispatch(new Authenticated('php-native-session', $user)); |
|
44 | |||
45 | 1 | $this->user = $user; |
|
46 | } |
||
47 | |||
48 | 1 | return $this->user; |
|
49 | } |
||
56 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.