Total Complexity | 7 |
Total Lines | 73 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | trait HasClosedFlagHelpers |
||
17 | { |
||
18 | public function initializeHasClosedFlagHelpers(): void |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Set closed flag. |
||
25 | * |
||
26 | * @return static |
||
27 | */ |
||
28 | public function setClosedFlag() |
||
29 | { |
||
30 | $this->setAttribute('is_closed', true); |
||
31 | |||
32 | return $this; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Unset closed flag. |
||
37 | * |
||
38 | * @return static |
||
39 | */ |
||
40 | public function unsetClosedFlag() |
||
41 | { |
||
42 | $this->setAttribute('is_closed', false); |
||
43 | |||
44 | return $this; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * If entity is closed. |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function isClosed(): bool |
||
53 | { |
||
54 | return $this->getAttributeValue('is_closed'); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * If entity is opened. |
||
59 | * |
||
60 | * @return bool |
||
61 | */ |
||
62 | public function isOpened(): bool |
||
63 | { |
||
64 | return !$this->isClosed(); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Mark entity as closed. |
||
69 | * |
||
70 | * @return void |
||
71 | */ |
||
72 | public function close(): void |
||
73 | { |
||
74 | $this->setClosedFlag()->save(); |
||
75 | |||
76 | $this->fireModelEvent('closed', false); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Mark entity as opened. |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | public function open(): void |
||
89 | } |
||
90 | } |
||
91 |