@@ 222-236 (lines=15) @@ | ||
219 | } |
|
220 | ||
221 | // class name is string |
|
222 | if (is_string($className)) { |
|
223 | $list = array_map( |
|
224 | function ($dataItem) use ($className) { |
|
225 | $listItemStructure = new $className(); |
|
226 | if (!($listItemStructure instanceof Structure)) { |
|
227 | throw new Exception('Wrong structure class specified'); |
|
228 | } |
|
229 | $listItemStructure->mergeUnmodified($dataItem); |
|
230 | return $listItemStructure; |
|
231 | }, |
|
232 | $data |
|
233 | ); |
|
234 | ||
235 | return $list; |
|
236 | } |
|
237 | ||
238 | // class name id callable |
|
239 | if (is_callable($className)) { |
|
@@ 239-249 (lines=11) @@ | ||
236 | } |
|
237 | ||
238 | // class name id callable |
|
239 | if (is_callable($className)) { |
|
240 | return array_map(function ($dataItem) use ($className) { |
|
241 | $classNameString = $className($dataItem); |
|
242 | $listItemStructure = new $classNameString; |
|
243 | if (!($listItemStructure instanceof Structure)) { |
|
244 | throw new Exception('Wrong structure class specified'); |
|
245 | } |
|
246 | ||
247 | return $listItemStructure->merge($dataItem); |
|
248 | }, $data); |
|
249 | } |
|
250 | ||
251 | throw new Exception('Wrong class name specified. Use string or closure'); |
|
252 | } |