| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 85.71% |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | #[Entity(repository: IdentityRepository::class)] |
||
| 15 | 20 | class Identity implements CookieLoginIdentityInterface |
|
| 16 | { |
||
| 17 | #[Column(type: 'primary')] |
||
| 18 | private ?int $id = null; |
||
|
|
|||
| 19 | |||
| 20 | #[Column(type: 'string(32)')] |
||
| 21 | private string $authKey; |
||
| 22 | |||
| 23 | #[BelongsTo(target: User::class, nullable: false, load: 'eager')] |
||
| 24 | private ?User $user = null; |
||
| 25 | private ?int $user_id = null; |
||
| 26 | |||
| 27 | 1 | public function __construct() |
|
| 28 | { |
||
| 29 | 1 | $this->regenerateCookieLoginKey(); |
|
| 30 | 1 | } |
|
| 31 | |||
| 32 | 1 | public function getId(): ?string |
|
| 33 | { |
||
| 34 | 1 | return $this->user->getId(); |
|
| 35 | } |
||
| 36 | |||
| 37 | 1 | public function getCookieLoginKey(): string |
|
| 38 | { |
||
| 39 | 1 | return $this->authKey; |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | public function getUser(): ?User |
|
| 43 | { |
||
| 44 | 1 | return $this->user; |
|
| 45 | } |
||
| 46 | |||
| 47 | public function validateCookieLoginKey(string $key): bool |
||
| 48 | { |
||
| 49 | return $this->authKey === $key; |
||
| 50 | } |
||
| 51 | |||
| 52 | 2 | public function regenerateCookieLoginKey(): void |
|
| 55 | 2 | } |
|
| 56 | } |
||
| 57 |