1 | <?php |
||
26 | trait Tracking |
||
27 | { |
||
28 | /** |
||
29 | * @var array<string,array<string,mixed>> Changes to persist. |
||
30 | */ |
||
31 | protected $changes = []; |
||
32 | |||
33 | /** |
||
34 | * Gets the pending changes. |
||
35 | * |
||
36 | * @return array<string,array<string,mixed>> The pending changes |
||
37 | */ |
||
38 | public function getChanges(): array |
||
42 | |||
43 | /** |
||
44 | * Whether the object has any changes. |
||
45 | * |
||
46 | * @return - Whether the object has any changes |
||
|
|||
47 | */ |
||
48 | public function isDirty(): bool |
||
52 | |||
53 | /** |
||
54 | * Sets a field for update. |
||
55 | * |
||
56 | * @param $field - The field name |
||
57 | * @param $value - The field value |
||
58 | * @return - provides a fluent interface |
||
59 | */ |
||
60 | protected function fieldSet(string $field, $value): self |
||
68 | |||
69 | /** |
||
70 | * Sets a field for removal. |
||
71 | * |
||
72 | * @param $field - The field name |
||
73 | * @return - provides a fluent interface |
||
74 | */ |
||
75 | protected function fieldUnset(string $field): self |
||
83 | |||
84 | /** |
||
85 | * Sets a field for increment. |
||
86 | * |
||
87 | * @param $field - The field name |
||
88 | * @param $value - Optional. The increment value. Default is `1`. |
||
89 | * @return - provides a fluent interface |
||
90 | */ |
||
91 | protected function fieldIncrement(string $field, int $value = 1): self |
||
99 | |||
100 | /** |
||
101 | * Sets a field to the current date. |
||
102 | * |
||
103 | * @param $field - The field name |
||
104 | * @return - provides a fluent interface |
||
105 | */ |
||
106 | protected function fieldNow(string $field): self |
||
114 | |||
115 | /** |
||
116 | * Pushes a value onto a field. |
||
117 | * |
||
118 | * @param $field - The field name |
||
119 | * @param $value - The value to push |
||
120 | * @return - provides a fluent interface |
||
121 | */ |
||
122 | protected function fieldPush(string $field, $value): self |
||
130 | |||
131 | /** |
||
132 | * Pushes a value onto an array field. |
||
133 | * |
||
134 | * @param $field - The field name |
||
135 | * @param $value - The values to push |
||
136 | * @return - provides a fluent interface |
||
137 | */ |
||
138 | protected function fieldPushAll(string $field, iterable $value): self |
||
146 | |||
147 | /** |
||
148 | * Pulls a value from a array field. |
||
149 | * |
||
150 | * In addition to a single value, you can also specify a query document. |
||
151 | * ``` |
||
152 | * $this->fieldPull('vegetables', 'carrot'); |
||
153 | * $this->fieldPull('listOfDocs', ['foo' => 'bar']); |
||
154 | * ``` |
||
155 | * |
||
156 | * @param $field - The field name |
||
157 | * @param $value - The value to pull |
||
158 | * @return - provides a fluent interface |
||
159 | */ |
||
160 | protected function fieldPull(string $field, $value): self |
||
168 | |||
169 | /** |
||
170 | * Takes all the changes from a `Modifiable` and copies them under a field name. |
||
171 | * |
||
172 | * @param $child - The object containing updates |
||
173 | * @param $field - The field name |
||
174 | * @return - provides a fluent interface |
||
175 | */ |
||
176 | protected function aggregateChanges(Modifiable $child, string $field): self |
||
188 | } |
||
189 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.