| Total Complexity | 12 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | trait TExpiration |
||
| 16 | { |
||
| 17 | /** @var int */ |
||
| 18 | protected $changeInterval = 31536000; // 60×60×24×365 - one year |
||
| 19 | /** @var int */ |
||
| 20 | protected $changeNotice = 2592000; // 60×60×24×30 - one month |
||
| 21 | |||
| 22 | 1 | protected function initExpiry(int $changeInterval, int $changeNoticeBefore): void |
|
| 23 | { |
||
| 24 | 1 | $this->changeInterval = $changeInterval; |
|
| 25 | 1 | $this->changeNotice = $changeNoticeBefore; |
|
| 26 | 1 | } |
|
| 27 | |||
| 28 | /** |
||
| 29 | * @param object|int|string $class |
||
| 30 | * @param int $nextChange |
||
| 31 | * @throws AuthSourcesException |
||
| 32 | */ |
||
| 33 | 3 | public function setExpirationNotice($class, int $nextChange): void |
|
| 37 | } |
||
| 38 | 3 | } |
|
| 39 | |||
| 40 | 1 | protected function shallExpire(int $nextChange): bool |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param object|int|string $class |
||
| 47 | * @throws AuthSourcesException |
||
| 48 | */ |
||
| 49 | 1 | public function updateExpirationTime($class): void |
|
| 53 | } |
||
| 54 | 1 | } |
|
| 55 | |||
| 56 | 3 | protected function whenItExpire(): int |
|
| 57 | { |
||
| 58 | 3 | return $this->getTime() + $this->changeInterval; |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @return int |
||
| 63 | * @codeCoverageIgnore too dynamic |
||
| 64 | */ |
||
| 65 | 2 | protected function getTime(): int |
|
| 68 | } |
||
| 69 | } |
||
| 70 |