Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Audit\Adapter; |
15 | |
16 | /** |
17 | * Auditor adapter interface |
18 | * |
19 | * @category Pop |
20 | * @package Pop\Audit |
21 | * @author Nick Sagona, III <dev@nolainteractive.com> |
22 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
23 | * @license http://www.popphp.org/license New BSD License |
24 | * @version 2.0.0 |
25 | */ |
26 | interface AdapterInterface |
27 | { |
28 | |
29 | /** |
30 | * Set the model name |
31 | * |
32 | * @param string $model |
33 | * @return AdapterInterface |
34 | */ |
35 | public function setModel(string $model): AdapterInterface; |
36 | |
37 | /** |
38 | * Set the model ID |
39 | * |
40 | * @param int|string $modelId |
41 | * @return AdapterInterface |
42 | */ |
43 | public function setModelId(int|string $modelId): AdapterInterface; |
44 | |
45 | /** |
46 | * Get the model name |
47 | * |
48 | * @return string|null |
49 | */ |
50 | public function getModel(): string|null; |
51 | |
52 | /** |
53 | * Get the model ID |
54 | * |
55 | * @return int|string|null |
56 | */ |
57 | public function getModelId(): int|string|null; |
58 | |
59 | /** |
60 | * Get the action |
61 | * |
62 | * @return string|null |
63 | */ |
64 | public function getAction(): string|null; |
65 | |
66 | /** |
67 | * Get the original model state differences |
68 | * |
69 | * @return array |
70 | */ |
71 | public function getOriginal(): array; |
72 | |
73 | /** |
74 | * Get the modified model state differences |
75 | * |
76 | * @return array |
77 | */ |
78 | public function getModified(): array; |
79 | |
80 | /** |
81 | * Set the username |
82 | * |
83 | * @param string $username |
84 | * @return AdapterInterface |
85 | */ |
86 | public function setUsername(string $username): AdapterInterface; |
87 | |
88 | /** |
89 | * Set the user ID |
90 | * |
91 | * @param int|string $userId |
92 | * @return AdapterInterface |
93 | */ |
94 | public function setUserId(int|string $userId): AdapterInterface; |
95 | |
96 | /** |
97 | * Set the domain |
98 | * |
99 | * @param string $domain |
100 | * @return AdapterInterface |
101 | */ |
102 | public function setDomain(string $domain): AdapterInterface; |
103 | |
104 | /** |
105 | * Set the route |
106 | * |
107 | * @param string $route |
108 | * @return AdapterInterface |
109 | */ |
110 | public function setRoute(string $route): AdapterInterface; |
111 | |
112 | /** |
113 | * Set the method |
114 | * |
115 | * @param string $method |
116 | * @return AdapterInterface |
117 | */ |
118 | public function setMethod(string $method): AdapterInterface; |
119 | |
120 | /** |
121 | * Set the metadata |
122 | * |
123 | * @param array $metadata |
124 | * @return AdapterInterface |
125 | */ |
126 | public function setMetadata(array $metadata): AdapterInterface; |
127 | |
128 | /** |
129 | * Add to the metadata |
130 | * |
131 | * @param string $name |
132 | * @param mixed $value |
133 | * @return AdapterInterface |
134 | */ |
135 | public function addMetadata(string $name, mixed $value): AdapterInterface; |
136 | |
137 | /** |
138 | * Get the username |
139 | * |
140 | * @return string|null |
141 | */ |
142 | public function getUsername(): string|null; |
143 | |
144 | /** |
145 | * Get the user ID |
146 | * |
147 | * @return int|string|null |
148 | */ |
149 | public function getUserId(): int|string|null; |
150 | |
151 | /** |
152 | * Get the domain |
153 | * |
154 | * @return string|null |
155 | */ |
156 | public function getDomain(): string|null; |
157 | |
158 | /** |
159 | * Get the route |
160 | * |
161 | * @return string|null |
162 | */ |
163 | public function getRoute(): string|null; |
164 | |
165 | /** |
166 | * Get the method |
167 | * |
168 | * @return string|null |
169 | */ |
170 | public function getMethod(): string|null; |
171 | |
172 | /** |
173 | * Determine if there is metadata |
174 | * |
175 | * @param ?string $name |
176 | * @return bool |
177 | */ |
178 | public function hasMetadata(?string $name = null): bool; |
179 | |
180 | /** |
181 | * Get the metadata |
182 | * |
183 | * @param ?string $name |
184 | * @return mixed |
185 | */ |
186 | public function getMetadata(?string $name = null): mixed; |
187 | |
188 | /** |
189 | * Set the final state data |
190 | * |
191 | * @param array $state |
192 | * @return AdapterInterface |
193 | */ |
194 | public function setStateData(array $state): AdapterInterface; |
195 | |
196 | /** |
197 | * Get the final state |
198 | * |
199 | * @param ?string $name |
200 | * @return mixed |
201 | */ |
202 | public function getStateData(?string $name = null): mixed; |
203 | |
204 | /** |
205 | * Determine if there is a final state |
206 | * |
207 | * @return bool |
208 | */ |
209 | public function hasStateData(): bool; |
210 | |
211 | /** |
212 | * Set the differences in values between the model states (that have already been processed) |
213 | * |
214 | * @param array $old |
215 | * @param array $new |
216 | * @return AdapterInterface |
217 | */ |
218 | public function setDiff(array $old, array $new): AdapterInterface; |
219 | |
220 | /** |
221 | * Resolve the differences in values between the model states |
222 | * |
223 | * @param array $old |
224 | * @param array $new |
225 | * @param bool $state |
226 | * @return AdapterInterface |
227 | */ |
228 | public function resolveDiff(array $old, array $new, bool $state = true): AdapterInterface; |
229 | |
230 | /** |
231 | * Check if the model states are different |
232 | * |
233 | * @return bool |
234 | */ |
235 | public function hasDiff(): bool; |
236 | |
237 | /** |
238 | * Prepare data |
239 | * |
240 | * @param bool $jsonEncode |
241 | * @return array |
242 | */ |
243 | public function prepareData(bool $jsonEncode = true): array; |
244 | |
245 | /** |
246 | * Send the results of the audit |
247 | * |
248 | * @return mixed |
249 | */ |
250 | public function send(): mixed; |
251 | |
252 | /** |
253 | * Get model states |
254 | * |
255 | * @return array |
256 | */ |
257 | public function getStates(): array; |
258 | |
259 | /** |
260 | * Get model state by ID |
261 | * |
262 | * @param int|string $id |
263 | * @return array |
264 | */ |
265 | public function getStateById(int|string $id): array; |
266 | |
267 | /** |
268 | * Get model state by model |
269 | * |
270 | * @param string $model |
271 | * @param int|string|null $modelId |
272 | * @return array |
273 | */ |
274 | public function getStateByModel(string $model, int|string|null $modelId = null): array; |
275 | |
276 | /** |
277 | * Get model state by timestamp |
278 | * |
279 | * @param string $from |
280 | * @param ?string $backTo |
281 | * @return array |
282 | */ |
283 | public function getStateByTimestamp(string $from, ?string $backTo = null): array; |
284 | |
285 | /** |
286 | * Get model state by date |
287 | * |
288 | * @param string $from |
289 | * @param string $backTo |
290 | * @return array |
291 | */ |
292 | public function getStateByDate(string $from, ?string $backTo = null): array; |
293 | |
294 | /** |
295 | * Get model snapshot by ID |
296 | * |
297 | * @param int|string $id |
298 | * @param bool $post |
299 | * @return array |
300 | */ |
301 | public function getSnapshot(int|string $id, bool $post = false): array; |
302 | |
303 | } |