Code Duplication    Length = 20-21 lines in 2 locations

src/Form/Field/HasMany.php 1 location

@@ 233-252 (lines=20) @@
230
                }, $newColumn);
231
                $newInputs = $array_clean_merge($newInputs, $newInput);
232
233
                $newAttributes = array_map(function ($v) use ($field, $availInput) {
234
                    list($r, $k, $c) = explode('.', $v);
235
                    //Fix ResetInput Function! A Headache Implementation!
236
                    $col = explode(':', $c)[0];
237
                    if (array_key_exists($col, $availInput[$k]) && is_array($availInput[$k][$col])) {
238
                        return call_user_func_array('array_merge', array_map(function ($u) use ($v, $field) {
239
                            $w = $field->label();
240
                            //Fix ResetInput Function! A Headache Implementation!
241
                            $w .= is_array($field->column()) ? '['.explode(':', explode('.', $v)[2])[0].']' : '';
242
243
                            return ["{$v}:{$u}" => $w];
244
                        }, array_keys($availInput[$k][$col])));
245
                    }
246
247
                    $w = $field->label();
248
                    //Fix ResetInput Function! A Headache Implementation!
249
                    $w .= is_array($field->column()) ? '['.explode(':', explode('.', $v)[2])[0].']' : '';
250
251
                    return [$v => $w];
252
                }, $newColumn);
253
                $attributes = $array_clean_merge($attributes, $newAttributes);
254
            }
255

src/Form/Field/Embeds.php 1 location

@@ 210-230 (lines=21) @@
207
                return !$k ? "{$rel}.{$v}" : "{$rel}.{$v}:{$k}";
208
            }, array_keys($columns), array_values($columns));
209
210
            $newAttributes = array_map(function ($v) use ($field, $availInput) {
211
                list($k, $c) = explode('.', $v);
212
                //Fix ResetInput Function! A Headache Implementation!
213
                $col = explode(':', $c)[0];
214
                if (array_key_exists($col, $availInput[$k]) && is_array($availInput[$k][$col])) {
215
                    return call_user_func_array('array_merge', array_map(function ($u) use ($v, $field) {
216
                        $w = $field->label();
217
                        //Fix ResetInput Function! A Headache Implementation!
218
                        $w .= is_array($field->column()) ? '['.explode(':', explode('.', $v)[2])[0].']' : '';
219
220
                        return ["{$v}:{$u}" => $w];
221
                    }, array_keys($availInput[$k][$col])));
222
                }
223
224
                //May Have Problem in Dealing with File Upload in Edit Mode
225
                $w = $field->label();
226
                //Fix ResetInput Function! A Headache Implementation!
227
                $w .= is_array($field->column()) ? '['.explode(':', explode('.', $v)[2])[0].']' : '';
228
229
                return [$v => $w];
230
            }, $newColumn);
231
            $attributes = $array_clean_merge($attributes, $newAttributes);
232
        }
233