HasFieldName::getTranslatedFieldName()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace BBSLab\NovaPermission\Traits;
4
5
use Illuminate\Support\Str;
6
7
trait HasFieldName
8
{
9
    protected function getTranslatedFieldName(string $name): string
10
    {
11
        $key = Str::snake($name);
12
13
        $validationAttributeKey = "validation.attributes.{$key}";
14
        $trans = __($validationAttributeKey);
15
16
        if ($trans !== $validationAttributeKey) {
17
            return ucfirst($trans);
18
        }
19
20
        return __($name);
21
    }
22
}
23