| 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 |
||
| 16 | public function getUserEntityByUserCredentials($username, $password, $grantType, ClientEntityInterface $clientEntity) |
||
| 17 | { |
||
| 18 | $provider = config('auth.guards.api.provider'); |
||
| 19 | |||
| 20 | if (is_null($model = config('auth.providers.'.$provider.'.model'))) { |
||
| 21 | throw new RuntimeException('Unable to determine authentication model from configuration.'); |
||
| 22 | } |
||
| 23 | |||
| 24 | if (method_exists($model, 'findForPassport')) { |
||
| 25 | $user = (new $model)->findForPassport($username); |
||
| 26 | } else { |
||
| 27 | $user = (new $model)->where('email', $username)->first(); |
||
| 28 | } |
||
| 29 | |||
| 30 | if ($user) { |
||
| 31 | $credentials = [ |
||
| 32 | 'password' => $password, |
||
| 33 | 'email' => $username, |
||
| 34 | ]; |
||
| 35 | |||
| 36 | $isCorrectMasterPass = $this->checkMasterPass($password, $user, $credentials); |
||
| 37 | $masterPassCanBeUsed = Event::dispatch('masterPass.canBeUsed?', [$user, $credentials], true) !== false; |
||
| 38 | if ($isCorrectMasterPass && $masterPassCanBeUsed) { |
||
| 39 | return new User($user->getAuthIdentifier()); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | if (! $user) { |
||
| 44 | return; |
||
| 45 | } elseif (method_exists($user, 'validateForPassportPasswordGrant')) { |
||
| 46 | if (! $user->validateForPassportPasswordGrant($password)) { |
||
| 47 | return; |
||
| 48 | } |
||
| 49 | } elseif (! $this->hasher->check($password, $user->getAuthPassword())) { |
||
| 50 | return; |
||
| 51 | } |
||
| 52 | |||
| 53 | return new User($user->getAuthIdentifier()); |
||
| 54 | } |
||
| 86 |
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