Code Duplication    Length = 20-21 lines in 2 locations

src/Form/Field/Embeds.php 1 location

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

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