Total Complexity | 6 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | trait HasNameAndTitle |
||
9 | { |
||
10 | /** |
||
11 | * The layout's unique identifier. |
||
12 | */ |
||
13 | protected string $name = ''; |
||
14 | |||
15 | /** |
||
16 | * The layout's human-readable title. |
||
17 | */ |
||
18 | protected string $title = ''; |
||
19 | |||
20 | /** |
||
21 | * Retrieve the layout's name (identifier) |
||
22 | */ |
||
23 | 23 | public function name(): string |
|
24 | { |
||
25 | 23 | if($this->name) { |
|
26 | 16 | return $this->name; |
|
27 | } |
||
28 | |||
29 | 18 | $className = class_basename(static::class); |
|
30 | 18 | if($className !== 'Layout' && Str::endsWith($className, 'Layout')) { |
|
31 | 16 | $className = Str::beforeLast($className, 'Layout'); |
|
32 | } |
||
33 | |||
34 | 18 | return Str::snake($className); |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Retrieve the layout's human-readable title |
||
39 | */ |
||
40 | 16 | public function title(): string |
|
47 | } |
||
48 | } |
||
49 |