| Total Complexity | 8 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | class ApiKeyUser implements ApiKeyUserInterface, UserInterface |
||
| 24 | { |
||
| 25 | private string $identifier; |
||
| 26 | private ApiKey $apiKey; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var array<int, string> |
||
| 30 | */ |
||
| 31 | private array $roles; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * {@inheritdoc} |
||
| 35 | */ |
||
| 36 | 34 | public function __construct(ApiKey $apiKey, array $roles) |
|
| 37 | { |
||
| 38 | 34 | $this->apiKey = $apiKey; |
|
| 39 | 34 | $this->identifier = $this->apiKey->getToken(); |
|
| 40 | 34 | $this->roles = array_unique(array_merge($roles, [RolesService::ROLE_API])); |
|
| 41 | 34 | } |
|
| 42 | |||
| 43 | 28 | public function getApiKey(): ApiKey |
|
| 44 | { |
||
| 45 | 28 | return $this->apiKey; |
|
| 46 | } |
||
| 47 | |||
| 48 | 24 | public function getRoles(): array |
|
| 49 | { |
||
| 50 | 24 | return $this->roles; |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @codeCoverageIgnore |
||
| 55 | */ |
||
| 56 | public function getPassword(): ?string |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @codeCoverageIgnore |
||
| 63 | */ |
||
| 64 | public function getSalt(): ?string |
||
| 65 | { |
||
| 66 | return null; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @codeCoverageIgnore |
||
| 71 | */ |
||
| 72 | public function eraseCredentials(): void |
||
| 74 | } |
||
| 75 | |||
| 76 | 3 | public function getUserIdentifier(): string |
|
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @todo Remove this method when Symfony 6.0.0 is released |
||
| 83 | * |
||
| 84 | * @codeCoverageIgnore |
||
| 85 | */ |
||
| 86 | public function getUsername(): string |
||
| 89 | } |
||
| 90 | } |
||
| 91 |