Code Duplication    Length = 26-26 lines in 2 locations

src/Form/Field/HasMany.php 1 location

@@ 292-317 (lines=26) @@
289
     *
290
     * @return array
291
     */
292
    protected function formatValidationAttribute($input, $label, $column)
293
    {
294
        $new = $attributes = [];
295
296
        if (is_array($column)) {
297
            foreach ($column as $index => $col) {
298
                $new[$col.$index] = $col;
299
            }
300
        }
301
302
        foreach (array_keys(array_dot($input)) as $key) {
303
            if (is_string($column)) {
304
                if (Str::endsWith($key, ".$column")) {
305
                    $attributes[$key] = $label;
306
                }
307
            } else {
308
                foreach ($new as $k => $val) {
309
                    if (Str::endsWith($key, ".$k")) {
310
                        $attributes[$key] = $label."[$val]";
311
                    }
312
                }
313
            }
314
        }
315
316
        return $attributes;
317
    }
318
319
    /**
320
     * Reset input key for validation.

src/Form/Field/Embeds.php 1 location

@@ 254-279 (lines=26) @@
251
     *
252
     * @return array
253
     */
254
    protected function formatValidationAttribute($input, $label, $column)
255
    {
256
        $new = $attributes = [];
257
258
        if (is_array($column)) {
259
            foreach ($column as $index => $col) {
260
                $new[$col.$index] = $col;
261
            }
262
        }
263
264
        foreach (array_keys(array_dot($input)) as $key) {
265
            if (is_string($column)) {
266
                if (Str::endsWith($key, ".$column")) {
267
                    $attributes[$key] = $label;
268
                }
269
            } else {
270
                foreach ($new as $k => $val) {
271
                    if (Str::endsWith($key, ".$k")) {
272
                        $attributes[$key] = $label."[$val]";
273
                    }
274
                }
275
            }
276
        }
277
278
        return $attributes;
279
    }
280
281
    /**
282
     * Reset input key for validation.