GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

StorageUserProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Security\ApiKey;
6
7
use Damax\Bundle\ApiAuthBundle\Key\Storage\KeyNotFound;
8
use Damax\Bundle\ApiAuthBundle\Key\Storage\Reader as Storage;
9
use Damax\Bundle\ApiAuthBundle\Security\ApiUser;
10
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
11
use Symfony\Component\Security\Core\User\UserInterface;
12
13
final class StorageUserProvider implements ApiKeyUserProvider
14
{
15
    private $storage;
16
17
    public function __construct(Storage $storage)
18
    {
19
        $this->storage = $storage;
20
    }
21
22
    public function supportsClass($class): bool
23
    {
24
        return ApiUser::class === $class;
25
    }
26
27
    public function loadUserByUsername($username): UserInterface
28
    {
29
        return new ApiUser($username);
30
    }
31
32
    public function loadUserByApiKey(string $apiKey): UserInterface
33
    {
34
        try {
35
            $key = $this->storage->get($apiKey);
36
        } catch (KeyNotFound $e) {
37
            throw new InvalidApiKey();
38
        }
39
40
        if ($key->expired()) {
41
            throw new InvalidApiKey();
42
        }
43
44
        return $this->loadUserByUsername($key->identity());
45
    }
46
47
    /**
48
     * @throws UnsupportedUserException
49
     */
50
    public function refreshUser(UserInterface $user): UserInterface
51
    {
52
        throw new UnsupportedUserException(sprintf('Provider "%s" must be configured as stateless.', __CLASS__));
53
    }
54
}
55