1 | <?php |
||
20 | trait ObjectByString |
||
21 | { |
||
22 | |||
23 | use Object; |
||
24 | |||
25 | /** |
||
26 | * @var BaseObject[] |
||
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 BaseObject |
||
39 | */ |
||
40 | abstract protected function findByRecord(Record $record, string $toScenario = null): BaseObject; |
||
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | protected function recordStringProperty(): string |
||
49 | |||
50 | /** |
||
51 | * @param BaseObject $object |
||
52 | * @return string |
||
53 | */ |
||
54 | protected function stringValue(BaseObject $object) |
||
61 | |||
62 | /******************************************* |
||
63 | * FIND/GET BY STRING |
||
64 | *******************************************/ |
||
65 | |||
66 | /** |
||
67 | * @param string $string |
||
68 | * @param string|null $toScenario |
||
69 | * @return BaseObject|null |
||
70 | */ |
||
71 | public function findByString(string $string, string $toScenario = null) |
||
88 | |||
89 | /** |
||
90 | * @param string $string |
||
91 | * @param string|null $toScenario |
||
92 | * @return BaseObject|null |
||
93 | * @throws ObjectNotFoundException |
||
94 | */ |
||
95 | public function getByString(string $string, string $toScenario = null): BaseObject |
||
104 | |||
105 | /** |
||
106 | * @param string $string |
||
107 | * @param string|null $toScenario |
||
108 | * @return BaseObject|null |
||
109 | */ |
||
110 | public function freshFindByString(string $string, string $toScenario = null) |
||
120 | |||
121 | /** |
||
122 | * @param string $string |
||
123 | * @param string|null $toScenario |
||
124 | * @return BaseObject |
||
125 | * @throws ObjectNotFoundException |
||
126 | */ |
||
127 | public function freshGetByString(string $string, string $toScenario = null): BaseObject |
||
136 | |||
137 | /******************************************* |
||
138 | * CACHE |
||
139 | *******************************************/ |
||
140 | |||
141 | /** |
||
142 | * Find an existing cache by string |
||
143 | * |
||
144 | * @param string $string |
||
145 | * @return null |
||
146 | */ |
||
147 | public function findCacheByString(string $string) |
||
157 | |||
158 | /** |
||
159 | * Identify whether in cache by string |
||
160 | * |
||
161 | * @param string $string |
||
162 | * @return bool |
||
163 | */ |
||
164 | private function isCachedByString(string $string): bool |
||
168 | |||
169 | |||
170 | /** |
||
171 | * @param BaseObject $model |
||
172 | * @return static |
||
173 | */ |
||
174 | protected function cacheByString(BaseObject $model) |
||
191 | |||
192 | /** |
||
193 | * @param Record $record |
||
194 | * @return BaseObject|null |
||
195 | */ |
||
196 | protected function findCacheByRecordByString(Record $record) |
||
209 | |||
210 | /******************************************* |
||
211 | * RECORD BY STRING |
||
212 | *******************************************/ |
||
213 | |||
214 | /** |
||
215 | * @param string $string |
||
216 | * @param string|null $toScenario |
||
217 | * @return Record|null |
||
218 | */ |
||
219 | public function findRecordByString(string $string, string $toScenario = null) |
||
229 | |||
230 | /** |
||
231 | * @param string $string |
||
232 | * @param string|null $toScenario |
||
233 | * @throws RecordNotFoundException |
||
234 | * @return Record|null |
||
235 | */ |
||
236 | public function getRecordByString(string $string, string $toScenario = null) |
||
245 | |||
246 | /******************************************* |
||
247 | * EXCEPTIONS |
||
248 | *******************************************/ |
||
249 | |||
250 | /** |
||
251 | * @param string|null $string |
||
252 | * @throws ObjectNotFoundException |
||
253 | */ |
||
254 | protected function notFoundByStringException(string $string = null) |
||
264 | |||
265 | /** |
||
266 | * @param string|null $string |
||
267 | * @throws RecordNotFoundException |
||
268 | */ |
||
269 | protected function notFoundRecordByStringException(string $string = null) |
||
279 | } |
||
280 |
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.