HasFieldName   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTranslatedFieldName() 0 13 2
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