| Total Complexity | 9 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class ApiKey extends AbstractEntity |
||
| 12 | { |
||
| 13 | private string $key; |
||
| 14 | private ?Chronos $expirationDate = null; |
||
| 15 | private bool $enabled; |
||
| 16 | |||
| 17 | 10 | public function __construct(?Chronos $expirationDate = null) |
|
| 18 | { |
||
| 19 | 10 | $this->key = Uuid::uuid4()->toString(); |
|
| 20 | 10 | $this->expirationDate = $expirationDate; |
|
| 21 | 10 | $this->enabled = true; |
|
| 22 | 10 | } |
|
| 23 | |||
| 24 | 4 | public function getExpirationDate(): ?Chronos |
|
| 25 | { |
||
| 26 | 4 | return $this->expirationDate; |
|
| 27 | } |
||
| 28 | |||
| 29 | 5 | public function isExpired(): bool |
|
| 32 | } |
||
| 33 | |||
| 34 | 7 | public function isEnabled(): bool |
|
| 35 | { |
||
| 36 | 7 | return $this->enabled; |
|
| 37 | } |
||
| 38 | |||
| 39 | 2 | public function disable(): self |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Tells if this api key is enabled and not expired |
||
| 47 | */ |
||
| 48 | 4 | public function isValid(): bool |
|
| 51 | } |
||
| 52 | |||
| 53 | 4 | public function __toString(): string |
|
| 56 | } |
||
| 57 | } |
||
| 58 |