BaseEnum   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __() 0 13 2
1
<?php
2
3
namespace Modules\Core\Enums;
4
5
use Illuminate\Support\Arr;
6
use Illuminate\Support\Str;
7
8
class BaseEnum
9
{
10
    protected const __ = [];
11
12
    /**
13
     * @param int $enum
14
     *
15
     * @return array|string|null
16
     */
17
    public static function __(int $enum)
18
    {
19
        $callClass = get_called_class();
20
        $module = strtolower(Str::before(Str::after($callClass, 'Modules\\'), '\\'));
21
        $scope = Str::camel(Str::before(Str::after($callClass, 'Enums\\'), 'Enum'));
22
23
        if (!Arr::has(static::__, $enum)) {
24
            return __('core::default.translator_key_is_not_found');
25
        }
26
27
        $key = static::__[$enum];
28
29
        return __("{$module}::{$scope}.{$key}");
30
    }
31
}
32