EuLoginUserProvider::loadUserByUsername()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @see https://github.com/ecphp
8
 */
9
10
declare(strict_types=1);
11
12
namespace EcPhp\EuLoginBundle\Security\Core\User;
13
14
use EcPhp\CasBundle\Security\Core\User\CasUserInterface;
15
use EcPhp\CasBundle\Security\Core\User\CasUserProviderInterface;
16
use Psr\Http\Message\ResponseInterface;
17
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
18
use Symfony\Component\Security\Core\User\UserInterface;
19
20
use function get_class;
21
22
final class EuLoginUserProvider implements CasUserProviderInterface
23
{
24
    /**
25
     * @var CasUserProviderInterface
26
     */
27
    private $casUserProvider;
28
29 5
    public function __construct(CasUserProviderInterface $casUserProvider)
30
    {
31 5
        $this->casUserProvider = $casUserProvider;
32
    }
33
34
    public function loadUserByIdentifier(string $identifier): UserInterface
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

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

34
    public function loadUserByIdentifier(/** @scrutinizer ignore-unused */ string $identifier): UserInterface

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    {
36
        throw new UnsupportedUserException('Unsupported operation.');
37
    }
38
39 1
    public function loadUserByResponse(ResponseInterface $response): CasUserInterface
40
    {
41 1
        return new EuLoginUser($this->casUserProvider->loadUserByResponse($response));
42
    }
43
44 1
    public function loadUserByUsername(string $username)
45
    {
46 1
        throw new UnsupportedUserException(sprintf('Username "%s" does not exist.', $username));
47
    }
48
49 1
    public function refreshUser(UserInterface $user)
50
    {
51 1
        if (!$user instanceof EuLoginUserInterface) {
52 1
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
53
        }
54
55 1
        return $user;
56
    }
57
58 1
    public function supportsClass(string $class)
59
    {
60 1
        return EuLoginUser::class === $class;
61
    }
62
}
63