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 (https://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@noladev.com> |
7 | * @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC. |
8 | * @license https://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Model; |
15 | |
16 | use Pop\Db\Record; |
17 | use Pop\Db\Record\Collection; |
18 | |
19 | /** |
20 | * Data model interface |
21 | * |
22 | * @category Pop |
23 | * @package Pop\Module |
24 | * @author Nick Sagona, III <dev@noladev.com> |
25 | * @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC. |
26 | * @license https://www.popphp.org/license New BSD License |
27 | * @version 4.3.5 |
28 | */ |
29 | interface DataModelInterface |
30 | { |
31 | |
32 | /** |
33 | * Get all |
34 | * |
35 | * @param ?string $sort |
36 | * @param mixed $limit |
37 | * @param mixed $page |
38 | * @param bool|array $toArray |
39 | * @throws Exception |
40 | * @return array|Collection |
41 | */ |
42 | public function getAll(?string $sort = null, mixed $limit = null, mixed $page = null, bool|array $toArray = false): array|Collection; |
43 | |
44 | /** |
45 | * Get by ID |
46 | * |
47 | * @param mixed $id |
48 | * @param bool $toArray |
49 | * @throws Exception |
50 | * @return array|Record |
51 | */ |
52 | public function getById(mixed $id, bool $toArray = false): array|Record; |
53 | |
54 | /** |
55 | * Create |
56 | * |
57 | * @param array $data |
58 | * @return mixed |
59 | */ |
60 | public function create(array $data): mixed; |
61 | |
62 | /** |
63 | * Replace |
64 | * |
65 | * @param mixed $id |
66 | * @param array $data |
67 | * @return mixed |
68 | */ |
69 | public function replace(mixed $id, array $data): mixed; |
70 | |
71 | /** |
72 | * Update |
73 | * |
74 | * @param mixed $id |
75 | * @param array $data |
76 | * @return mixed |
77 | */ |
78 | public function update(mixed $id, array $data): mixed; |
79 | |
80 | /** |
81 | * Delete |
82 | * |
83 | * @param mixed $id |
84 | * @throws Exception |
85 | * @return int |
86 | */ |
87 | public function delete(mixed $id): int; |
88 | |
89 | /** |
90 | * Remove multiple |
91 | * |
92 | * @param array $ids |
93 | * @throws Exception |
94 | * @return int |
95 | */ |
96 | public function remove(array $ids): int; |
97 | |
98 | /** |
99 | * Get count |
100 | * |
101 | * @throws Exception |
102 | * @return int |
103 | */ |
104 | public function count(): int; |
105 | |
106 | /** |
107 | * Method to describe columns in the database table |
108 | * |
109 | * @param bool $native Show the native columns in the table |
110 | * @param bool $full Used with the native flag, returns array of "column" => "type" |
111 | * @throws Exception |
112 | * @return array |
113 | */ |
114 | public function describe(bool $native = false, bool $full = false): array; |
115 | |
116 | /** |
117 | * Method to check if model has requirements or validations |
118 | * |
119 | * @return bool |
120 | */ |
121 | public function hasRequirements(): bool; |
122 | |
123 | /** |
124 | * Method to validate model data |
125 | * |
126 | * @param array $data |
127 | * @return bool|array |
128 | */ |
129 | public function validate(array $data): bool|array; |
130 | |
131 | /** |
132 | * Set filters |
133 | * |
134 | * @param mixed $filters |
135 | * @param mixed $select |
136 | * @return DataModelInterface |
137 | */ |
138 | public function filter(mixed $filters = null, mixed $select = null): DataModelInterface; |
139 | |
140 | /** |
141 | * Set select columns |
142 | * |
143 | * @param mixed $select |
144 | * @return DataModelInterface |
145 | */ |
146 | public function select(mixed $select = null): DataModelInterface; |
147 | |
148 | /** |
149 | * Get table class |
150 | * |
151 | * @return string |
152 | */ |
153 | public function getTableClass(): string; |
154 | |
155 | /** |
156 | * Get table primary ID |
157 | * |
158 | * @return string |
159 | */ |
160 | public function getPrimaryId(): string; |
161 | |
162 | /** |
163 | * Get offset and limit |
164 | * |
165 | * @param mixed $page |
166 | * @param mixed $limit |
167 | * @return array |
168 | */ |
169 | public function getOffsetAndLimit(mixed $page = null, mixed $limit = null): array; |
170 | |
171 | /** |
172 | * Get order by |
173 | * |
174 | * @param mixed $sort |
175 | * @param bool $toArray |
176 | * @return string|array|null |
177 | */ |
178 | public function getOrderBy(mixed $sort = null, bool $toArray = false): string|array|null; |
179 | |
180 | /** |
181 | * Method to parse filter for select predicates |
182 | * |
183 | * @param mixed $filter |
184 | * @return array |
185 | */ |
186 | public function parseFilter(mixed $filter): array; |
187 | |
188 | } |