Conditions | 10 |
Paths | 23 |
Total Lines | 38 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
17 | public function getUserEntityByUserCredentials($username, $password, $grantType, ClientEntityInterface $clientEntity) |
||
18 | { |
||
19 | $provider = config('auth.guards.api.provider'); |
||
20 | |||
21 | if (is_null($model = config('auth.providers.'.$provider.'.model'))) { |
||
22 | throw new RuntimeException('Unable to determine authentication model from configuration.'); |
||
23 | } |
||
24 | |||
25 | if (method_exists($model, 'findForPassport')) { |
||
26 | $user = (new $model)->findForPassport($username); |
||
27 | } else { |
||
28 | $user = (new $model)->where('email', $username)->first(); |
||
29 | } |
||
30 | |||
31 | if ($user) { |
||
32 | $credentials = [ |
||
33 | 'password' => $password, |
||
34 | 'email' => $username, |
||
35 | ]; |
||
36 | |||
37 | $isCorrectMasterPass = $this->checkMasterPass($password, $user, $credentials); |
||
38 | $masterPassCanBeUsed = Event::dispatch('masterPass.canBeUsed?', [$user, $credentials], true) !== false; |
||
39 | if ($isCorrectMasterPass && $masterPassCanBeUsed) { |
||
40 | return new User($user->getAuthIdentifier()); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | if (! $user) { |
||
45 | return; |
||
46 | } elseif (method_exists($user, 'validateForPassportPasswordGrant')) { |
||
47 | if (! $user->validateForPassportPasswordGrant($password)) { |
||
48 | return; |
||
49 | } |
||
50 | } elseif (! $this->hasher->check($password, $user->getAuthPassword())) { |
||
51 | return; |
||
52 | } |
||
53 | |||
54 | return new User($user->getAuthIdentifier()); |
||
55 | } |
||
87 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths