Test Failed
Pull Request — master (#88)
by Artem
04:05
created

UserResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 23
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 12 3
1
<?php
2
3
namespace Slides\Saml2\Resolvers;
4
5
use Illuminate\Database\Eloquent;
6
use Illuminate\Foundation\Auth\User;
0 ignored issues
show
Bug introduced by
The type Illuminate\Foundation\Auth\User was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Illuminate\Support\Facades\Auth;
8
use Slides\Saml2\Auth as SamlAuth;
9
use Slides\Saml2\Concerns\UserResolverHelpers;
10
use Slides\Saml2\Contracts\ResolvesUser;
11
use Slides\Saml2\Exceptions\ConfigurationException;
12
use Slides\Saml2\Exceptions\UserResolutionException;
13
14
class UserResolver implements ResolvesUser
15
{
16
    use UserResolverHelpers;
17
18
    /**
19
     * Resolve a user from the request.
20
     *
21
     * @param SamlAuth $samlAuth
22
     *
23
     * @return User|Eloquent|null
24
     */
25
    public function resolve(SamlAuth $samlAuth)
26
    {
27
        if (!$email = $this->resolveUserEmail($samlAuth->getSaml2User())) {
28
            throw new UserResolutionException('Unable to resolve user email', $samlAuth->getSaml2User());
29
        }
30
31
        if (!$provider = config('auth.defaults.passwords')) {
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        if (!$provider = /** @scrutinizer ignore-call */ config('auth.defaults.passwords')) {
Loading history...
32
            throw new ConfigurationException('No default password provider configured');
33
        }
34
35
        // Attempt to retrieve user by email.
36
        return Auth::createUserProvider($provider)->retrieveByCredentials(['email' => $email]);
37
    }
38
}
39