1 | <?php |
||
20 | trait ModelByString |
||
21 | { |
||
22 | |||
23 | use Model; |
||
24 | |||
25 | /** |
||
26 | * @var BaseModel[] |
||
27 | */ |
||
28 | protected $cacheByString = []; |
||
29 | |||
30 | /** |
||
31 | * @return string |
||
32 | */ |
||
33 | abstract protected function stringProperty(): string; |
||
34 | |||
35 | /** |
||
36 | * @param Record $record |
||
37 | * @param string|null $toScenario |
||
38 | * @return BaseModel |
||
39 | */ |
||
40 | abstract protected function findByRecord(Record $record, string $toScenario = null): BaseModel; |
||
41 | |||
42 | /** |
||
43 | * @param array $config |
||
44 | * @param string|null $toScenario |
||
45 | * @return BaseModel |
||
46 | */ |
||
47 | abstract public function create($config = [], string $toScenario = null): BaseModel; |
||
48 | |||
49 | /** |
||
50 | * @return string |
||
51 | */ |
||
52 | protected function recordStringProperty(): string |
||
56 | |||
57 | /** |
||
58 | * @param BaseModel $model |
||
59 | * @return string |
||
60 | */ |
||
61 | protected function stringValue(BaseModel $model) |
||
68 | |||
69 | /******************************************* |
||
70 | * FIND/GET BY STRING |
||
71 | *******************************************/ |
||
72 | |||
73 | /** |
||
74 | * @param string $string |
||
75 | * @param string|null $toScenario |
||
76 | * @return BaseModel|null |
||
77 | */ |
||
78 | public function findByString(string $string, string $toScenario = null) |
||
95 | |||
96 | /** |
||
97 | * @param string $string |
||
98 | * @param string|null $toScenario |
||
99 | * @return BaseModel|null |
||
100 | * @throws ModelNotFoundException |
||
101 | */ |
||
102 | public function getByString(string $string, string $toScenario = null): BaseModel |
||
111 | |||
112 | /** |
||
113 | * @param string $string |
||
114 | * @param string|null $toScenario |
||
115 | * @return BaseModel|null |
||
116 | */ |
||
117 | public function freshFindByString(string $string, string $toScenario = null) |
||
129 | |||
130 | /** |
||
131 | * @param string $string |
||
132 | * @param string|null $toScenario |
||
133 | * @return BaseModel |
||
134 | * @throws ModelNotFoundException |
||
135 | */ |
||
136 | public function freshGetByString(string $string, string $toScenario = null): BaseModel |
||
145 | |||
146 | /******************************************* |
||
147 | * CACHE |
||
148 | *******************************************/ |
||
149 | |||
150 | /** |
||
151 | * Find an existing cache by string |
||
152 | * |
||
153 | * @param string $string |
||
154 | * @return null |
||
155 | */ |
||
156 | public function findCacheByString(string $string) |
||
166 | |||
167 | /** |
||
168 | * Identify whether in cache by string |
||
169 | * |
||
170 | * @param string $string |
||
171 | * @return bool |
||
172 | */ |
||
173 | private function isCachedByString(string $string): bool |
||
177 | |||
178 | |||
179 | /** |
||
180 | * @param BaseModel $model |
||
181 | * @return static |
||
182 | */ |
||
183 | protected function cacheByString(BaseModel $model) |
||
200 | |||
201 | /** |
||
202 | * @param Record $record |
||
203 | * @return BaseModel|null |
||
204 | */ |
||
205 | protected function findCacheByRecordByString(Record $record) |
||
218 | |||
219 | /******************************************* |
||
220 | * RECORD BY STRING |
||
221 | *******************************************/ |
||
222 | |||
223 | /** |
||
224 | * @param string $string |
||
225 | * @param string|null $toScenario |
||
226 | * @return Record|null |
||
227 | */ |
||
228 | public function findRecordByString(string $string, string $toScenario = null) |
||
238 | |||
239 | /** |
||
240 | * @param string $string |
||
241 | * @param string|null $toScenario |
||
242 | * @throws RecordNotFoundException |
||
243 | * @return Record|null |
||
244 | */ |
||
245 | public function getRecordByString(string $string, string $toScenario = null) |
||
254 | |||
255 | /******************************************* |
||
256 | * EXCEPTIONS |
||
257 | *******************************************/ |
||
258 | |||
259 | /** |
||
260 | * @param string|null $string |
||
261 | * @throws ModelNotFoundException |
||
262 | */ |
||
263 | protected function notFoundByStringException(string $string = null) |
||
273 | |||
274 | /** |
||
275 | * @param string|null $string |
||
276 | * @throws RecordNotFoundException |
||
277 | */ |
||
278 | protected function notFoundRecordByStringException(string $string = null) |
||
288 | } |
||
289 |
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.