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

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