1 | <?php |
||
24 | trait ModelById |
||
25 | { |
||
26 | |||
27 | use Model; |
||
28 | |||
29 | /** |
||
30 | * @var ModelWithId[] |
||
31 | */ |
||
32 | protected $cacheById = []; |
||
33 | |||
34 | /** |
||
35 | * @param Record $record |
||
36 | * @param string|null $toScenario |
||
37 | * @return BaseModel|ModelWithId |
||
38 | */ |
||
39 | abstract protected function findByRecord(Record $record, string $toScenario = null): BaseModel; |
||
40 | |||
41 | /** |
||
42 | * @param array $config |
||
43 | * @param string|null $toScenario |
||
44 | * @return BaseModel|ModelWithId |
||
45 | */ |
||
46 | abstract public function create($config = [], string $toScenario = null): BaseModel; |
||
47 | |||
48 | /******************************************* |
||
49 | * FIND/GET BY ID |
||
50 | *******************************************/ |
||
51 | |||
52 | /** |
||
53 | * @param int $id |
||
54 | * @param string|null $toScenario |
||
55 | * @return ModelWithId|null |
||
56 | */ |
||
57 | public function findById(int $id, string $toScenario = null) |
||
74 | |||
75 | /** |
||
76 | * @param int $id |
||
77 | * @param string|null $toScenario |
||
78 | * @return ModelWithId|null |
||
79 | * @throws ModelNotFoundException |
||
80 | */ |
||
81 | public function getById(int $id, string $toScenario = null): ModelWithId |
||
90 | |||
91 | /** |
||
92 | * @param int $id |
||
93 | * @param string|null $toScenario |
||
94 | * @return ModelWithId|null |
||
95 | */ |
||
96 | public function freshFindById(int $id, string $toScenario = null) |
||
108 | |||
109 | /** |
||
110 | * @param int $id |
||
111 | * @param string|null $toScenario |
||
112 | * @return ModelWithId |
||
113 | * @throws ModelNotFoundException |
||
114 | */ |
||
115 | public function freshGetById(int $id, string $toScenario = null): ModelWithId |
||
124 | |||
125 | /******************************************* |
||
126 | * CACHE |
||
127 | *******************************************/ |
||
128 | |||
129 | /** |
||
130 | * Find an existing cache by id |
||
131 | * |
||
132 | * @param int $id |
||
133 | * @return null |
||
134 | */ |
||
135 | public function findCacheById(int $id) |
||
145 | |||
146 | /** |
||
147 | * Identify whether in cache by id |
||
148 | * |
||
149 | * @param int $id |
||
150 | * @return bool |
||
151 | */ |
||
152 | private function isCachedById(int $id): bool |
||
156 | |||
157 | |||
158 | /** |
||
159 | * @param ModelWithId $model |
||
160 | * @return static |
||
161 | */ |
||
162 | protected function cacheById(ModelWithId $model) |
||
177 | |||
178 | /** |
||
179 | * @param RecordWithId $record |
||
180 | * @return ModelWithId|null |
||
181 | */ |
||
182 | protected function findCacheByRecordById(RecordWithId $record) |
||
193 | |||
194 | /******************************************* |
||
195 | * RECORD BY ID |
||
196 | *******************************************/ |
||
197 | |||
198 | /** |
||
199 | * @param int $id |
||
200 | * @param string|null $toScenario |
||
201 | * @return RecordWithId|null |
||
202 | */ |
||
203 | public function findRecordById(int $id, string $toScenario = null) |
||
213 | |||
214 | /** |
||
215 | * @param int $id |
||
216 | * @param string|null $toScenario |
||
217 | * @return Record|RecordWithId|null |
||
218 | */ |
||
219 | public function getRecordById(int $id, string $toScenario = null): Record |
||
228 | |||
229 | |||
230 | /******************************************* |
||
231 | * EXCEPTIONS |
||
232 | *******************************************/ |
||
233 | |||
234 | /** |
||
235 | * @param int|null $id |
||
236 | * @throws ModelNotFoundException |
||
237 | */ |
||
238 | protected function notFoundByIdException(int $id = null) |
||
248 | |||
249 | /** |
||
250 | * @param int|null $id |
||
251 | * @throws RecordNotFoundException |
||
252 | */ |
||
253 | protected function notFoundRecordByIdException(int $id = null) |
||
263 | } |
||
264 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.