Code Duplication    Length = 20-21 lines in 2 locations

src/Form/Field/Embeds.php 1 location

@@ 195-215 (lines=21) @@
192
                return !$k ? "{$rel}.{$v}" : "{$rel}.{$v}:{$k}";
193
            }, array_keys($columns), array_values($columns));
194
195
            $newAttributes = array_map(function ($v) use ($field, $availInput) {
196
                list($k, $c) = explode('.', $v);
197
                //Fix ResetInput Function! A Headache Implementation!
198
                $col = explode(':', $c)[0];
199
                if (array_key_exists($col, $availInput[$k]) && is_array($availInput[$k][$col])) {
200
                    return call_user_func_array('array_merge', array_map(function ($u) use ($v, $field) {
201
                        $w = $field->label();
202
                        //Fix ResetInput Function! A Headache Implementation!
203
                        $w .= is_array($field->column()) ? '[' . explode(':', explode('.', $v)[2])[0] . ']' : '';
204
205
                        return ["{$v}:{$u}" => $w];
206
                    }, array_keys($availInput[$k][$col])));
207
                }
208
209
                //May Have Problem in Dealing with File Upload in Edit Mode
210
                $w = $field->label();
211
                //Fix ResetInput Function! A Headache Implementation!
212
                $w .= is_array($field->column()) ? '[' . explode(':', explode('.', $v)[2])[0] . ']' : '';
213
214
                return [$v => $w];
215
            }, $newColumn);
216
            $attributes = $array_clean_merge($attributes, $newAttributes);
217
218
        }

src/Form/Field/HasMany.php 1 location

@@ 260-279 (lines=20) @@
257
                }, $newColumn);
258
                $newInputs = $array_clean_merge($newInputs, $newInput);
259
260
                $newAttributes = array_map(function ($v) use ($field, $availInput) {
261
                    list($r, $k, $c) = explode('.', $v);
262
                    //Fix ResetInput Function! A Headache Implementation!
263
                    $col = explode(':', $c)[0];
264
                    if (array_key_exists($col, $availInput[$k]) && is_array($availInput[$k][$col])) {
265
                        return call_user_func_array('array_merge', array_map(function ($u) use ($v, $field) {
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}:{$u}" => $w];
271
                        }, array_keys($availInput[$k][$col])));
272
                    }
273
    
274
                    //May Have Problem in Dealing with File Upload in Edit Mode
275
                    $w = $field->label();
276
                    //Fix ResetInput Function! A Headache Implementation!
277
                    $w .= is_array($field->column()) ? '[' . explode(':', explode('.', $v)[2])[0] . ']' : '';
278
279
                    return [$v => $w];
280
                }, $newColumn);
281
                $attributes = $array_clean_merge($attributes, $newAttributes);
282
            }