Code Duplication    Length = 26-26 lines in 2 locations

src/Form/Field/Embeds.php 1 location

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

src/Form/Field/HasMany.php 1 location

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