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

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