Code Duplication    Length = 20-21 lines in 2 locations

src/Form/Field/Embeds.php 1 location

@@ 251-271 (lines=21) @@
248
                return !$k ? "{$rel}.{$v}" : "{$rel}.{$v}:{$k}";
249
            }, array_keys($columns), array_values($columns));
250
251
            $newAttributes = array_map(function ($v) use ($field, $availInput) {
252
                list($k, $c) = explode('.', $v);
253
                //Fix ResetInput Function! A Headache Implementation!
254
                $col = explode(':', $c)[0];
255
                if (array_key_exists($col, $availInput[$k]) && is_array($availInput[$k][$col])) {
256
                    return call_user_func_array('array_merge', array_map(function ($u) use ($v, $field) {
257
                        $w = $field->label();
258
                        //Fix ResetInput Function! A Headache Implementation!
259
                        $w .= is_array($field->column()) ? '['.explode(':', explode('.', $v)[2])[0].']' : '';
260
261
                        return ["{$v}:{$u}" => $w];
262
                    }, array_keys($availInput[$k][$col])));
263
                }
264
265
                //May Have Problem in Dealing with File Upload in Edit Mode
266
                $w = $field->label();
267
                //Fix ResetInput Function! A Headache Implementation!
268
                $w .= is_array($field->column()) ? '['.explode(':', explode('.', $v)[2])[0].']' : '';
269
270
                return [$v => $w];
271
            }, $newColumn);
272
            $attributes = array_clean_merge($attributes, $newAttributes);
273
        }
274

src/Form/Field/HasMany.php 1 location

@@ 254-273 (lines=20) @@
251
                }, $newColumn);
252
                $newInputs = array_clean_merge($newInputs, $newInput);
253
254
                $newAttributes = array_map(function ($v) use ($field, $availInput) {
255
                    list($r, $k, $c) = explode('.', $v);
256
                    //Fix ResetInput Function! A Headache Implementation!
257
                    $col = explode(':', $c)[0];
258
                    if (array_key_exists($col, $availInput[$k]) && is_array($availInput[$k][$col])) {
259
                        return call_user_func_array('array_merge', array_map(function ($u) use ($v, $field) {
260
                            $w = $field->label();
261
                            //Fix ResetInput Function! A Headache Implementation!
262
                            $w .= is_array($field->column()) ? '['.explode(':', explode('.', $v)[2])[0].']' : '';
263
264
                            return ["{$v}:{$u}" => $w];
265
                        }, array_keys($availInput[$k][$col])));
266
                    }
267
268
                    $w = $field->label();
269
                    //Fix ResetInput Function! A Headache Implementation!
270
                    $w .= is_array($field->column()) ? '['.explode(':', explode('.', $v)[2])[0].']' : '';
271
272
                    return [$v => $w];
273
                }, $newColumn);
274
                $attributes = array_clean_merge($attributes, $newAttributes);
275
            }
276