| Total Complexity | 7 |
| Total Lines | 73 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | trait HasExpiredFlagHelpers |
||
| 17 | { |
||
| 18 | public function initializeHasExpiredFlagHelpers(): void |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Set expired flag. |
||
| 25 | * |
||
| 26 | * @return static |
||
| 27 | */ |
||
| 28 | public function setExpiredFlag() |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Unset expired flag. |
||
| 37 | * |
||
| 38 | * @return static |
||
| 39 | */ |
||
| 40 | public function unsetExpiredFlag() |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * If entity is expired. |
||
| 49 | * |
||
| 50 | * @return bool |
||
| 51 | */ |
||
| 52 | public function isExpired(): bool |
||
| 53 | { |
||
| 54 | return $this->getAttributeValue('is_expired'); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * If entity is opened. |
||
| 59 | * |
||
| 60 | * @return bool |
||
| 61 | */ |
||
| 62 | public function isUnexpired(): bool |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Mark entity as expired. |
||
| 69 | * |
||
| 70 | * @return void |
||
| 71 | */ |
||
| 72 | public function expire(): void |
||
| 73 | { |
||
| 74 | $this->setExpiredFlag()->save(); |
||
| 75 | |||
| 76 | $this->fireModelEvent('expired', false); |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Mark entity as opened. |
||
| 81 | * |
||
| 82 | * @return void |
||
| 83 | */ |
||
| 84 | public function unexpire(): void |
||
| 89 | } |
||
| 90 | } |
||
| 91 |