Code Duplication    Length = 44-44 lines in 2 locations

src/Attribute.php 1 location

@@ 225-268 (lines=44) @@
222
     * @return array
223
     *   The array, flattened.
224
     */
225
    private function ensureFlatArray($value)
226
    {
227
        switch (gettype($value)) {
228
            case 'string':
229
                $return = explode(
230
                    ' ',
231
                    $value
232
                );
233
                break;
234
235
            case 'array':
236
                $flat_array = iterator_to_array(
237
                    new \RecursiveIteratorIterator(
238
                        new \RecursiveArrayIterator(
239
                            $value
240
                        )
241
                    ),
242
                    false
243
                );
244
245
                $return = [];
246
                foreach ($flat_array as $item) {
247
                    $return = array_merge(
248
                        $return,
249
                        $this->normalizeValue($item)
250
                    );
251
                }
252
                break;
253
254
            case 'double':
255
            case 'integer':
256
                $return = array($value);
257
                break;
258
            case 'object':
259
            case 'boolean':
260
            case 'resource':
261
            case 'NULL':
262
            default:
263
                $return = array();
264
                break;
265
        }
266
267
        return $return;
268
    }
269
}
270

src/Attributes.php 1 location

@@ 337-380 (lines=44) @@
334
     * @return array
335
     *   The array, flattened.
336
     */
337
    private function ensureFlatArray($value)
338
    {
339
        switch (gettype($value)) {
340
            case 'string':
341
                $return = explode(
342
                    ' ',
343
                    $value
344
                );
345
                break;
346
347
            case 'array':
348
                $flat_array = iterator_to_array(
349
                    new \RecursiveIteratorIterator(
350
                        new \RecursiveArrayIterator(
351
                            $value
352
                        )
353
                    ),
354
                    false
355
                );
356
357
                $return = [];
358
                foreach ($flat_array as $item) {
359
                    $return = array_merge(
360
                        $return,
361
                        $this->normalizeValue($item)
362
                    );
363
                }
364
                break;
365
366
            case 'double':
367
            case 'integer':
368
                $return = array($value);
369
                break;
370
            case 'object':
371
            case 'boolean':
372
            case 'resource':
373
            case 'NULL':
374
            default:
375
                $return = array();
376
                break;
377
        }
378
379
        return array_filter($return, 'is_string');
380
    }
381
}
382