Code Duplication    Length = 20-21 lines in 2 locations

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

src/Form/Field/Embeds.php 1 location

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