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