| Total Complexity | 11 |
| Total Lines | 96 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | final class ApiGwAuthenticationUser implements ApiGwAuthenticationUserInterface |
||
| 13 | { |
||
| 14 | public string $sub; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * The user storage. |
||
| 18 | * |
||
| 19 | * @var array<mixed> |
||
| 20 | */ |
||
| 21 | private array $storage; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param array<mixed> $data |
||
| 25 | */ |
||
| 26 | 9 | public function __construct(string $username, array $data = []) |
|
| 27 | { |
||
| 28 | 9 | $this->sub = $username; |
|
| 29 | 9 | $this->storage = $data; |
|
| 30 | 9 | } |
|
| 31 | |||
| 32 | 3 | public static function createFromPayload($username, array $payload) |
|
| 33 | { |
||
| 34 | 3 | return new self($username, $payload); |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * {@inheritdoc} |
||
| 39 | */ |
||
| 40 | 1 | public function eraseCredentials(): void |
|
| 42 | 1 | } |
|
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | 1 | public function get(string $key, $default = null) |
|
| 48 | { |
||
| 49 | 1 | return $this->getStorage()[$key] ?? $default; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritdoc} |
||
| 54 | */ |
||
| 55 | 1 | public function getAttribute(string $key, $default = null) |
|
| 56 | { |
||
| 57 | 1 | return $this->getStorage()[$key] ?? $default; |
|
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * {@inheritdoc} |
||
| 62 | */ |
||
| 63 | 1 | public function getAttributes(): array |
|
| 64 | { |
||
| 65 | 1 | return $this->getStorage(); |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * {@inheritdoc} |
||
| 70 | */ |
||
| 71 | 1 | public function getPassword(): ?string |
|
| 72 | { |
||
| 73 | 1 | return null; |
|
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * {@inheritdoc} |
||
| 78 | */ |
||
| 79 | 1 | public function getRoles(): array |
|
| 80 | { |
||
| 81 | 1 | return ['IS_AUTHENTICATED_FULLY']; |
|
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * {@inheritdoc} |
||
| 86 | */ |
||
| 87 | 1 | public function getSalt(): ?string |
|
| 88 | { |
||
| 89 | 1 | return null; |
|
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * {@inheritdoc} |
||
| 94 | */ |
||
| 95 | 2 | public function getUsername(): string |
|
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Get the storage. |
||
| 102 | * |
||
| 103 | * @return array<mixed> |
||
| 104 | */ |
||
| 105 | 3 | private function getStorage(): array |
|
| 108 | } |
||
| 109 | } |
||
| 110 |