| Total Complexity | 5 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | trait HasExpiredAtHelpers |
||
| 19 | { |
||
| 20 | public function initializeHasExpiredAtHelpers(): void |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * If entity is expired. |
||
| 27 | * |
||
| 28 | * @return bool |
||
| 29 | */ |
||
| 30 | public function isExpired(): bool |
||
| 31 | { |
||
| 32 | return !is_null($this->getAttributeValue('expired_at')); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * If entity is opened. |
||
| 37 | * |
||
| 38 | * @return bool |
||
| 39 | */ |
||
| 40 | public function isUnexpired(): bool |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Mark entity as expired. |
||
| 47 | * |
||
| 48 | * @return void |
||
| 49 | */ |
||
| 50 | public function expire(): void |
||
| 51 | { |
||
| 52 | $this->setAttribute('expired_at', Date::now()); |
||
| 53 | $this->save(); |
||
| 54 | |||
| 55 | $this->fireModelEvent('expired', false); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Mark entity as opened. |
||
| 60 | * |
||
| 61 | * @return void |
||
| 62 | */ |
||
| 63 | public function unexpire(): void |
||
| 69 | } |
||
| 70 | } |
||
| 71 |