@@ 204-218 (lines=15) @@ | ||
201 | } |
|
202 | ||
203 | // class name is string |
|
204 | if(is_string($className)) { |
|
205 | $list = array_map( |
|
206 | function($dataItem) use($className) { |
|
207 | $listItemStructure = new $className(); |
|
208 | if(!($listItemStructure instanceof Structure)) { |
|
209 | throw new Exception('Wrong structure class specified'); |
|
210 | } |
|
211 | $listItemStructure->mergeUnmodified($dataItem); |
|
212 | return $listItemStructure; |
|
213 | }, |
|
214 | $data |
|
215 | ); |
|
216 | ||
217 | return $list; |
|
218 | } |
|
219 | ||
220 | // class name id callable |
|
221 | if(is_callable($className)) { |
|
@@ 221-231 (lines=11) @@ | ||
218 | } |
|
219 | ||
220 | // class name id callable |
|
221 | if(is_callable($className)) { |
|
222 | return array_map(function($dataItem) use( $className) { |
|
223 | $classNameString = $className($dataItem); |
|
224 | $listItemStructure = new $classNameString; |
|
225 | if(!($listItemStructure instanceof Structure)) { |
|
226 | throw new Exception('Wrong structure class specified'); |
|
227 | } |
|
228 | ||
229 | return $listItemStructure->merge($dataItem); |
|
230 | }, $data); |
|
231 | } |
|
232 | ||
233 | throw new Exception('Wrong class name specified. Use string or closure'); |
|
234 | } |