Code Duplication    Length = 26-26 lines in 2 locations

src/Form/Field/Embeds.php 1 location

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

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.