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