Meta   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 27
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A method() 0 7 2
A make() 0 3 1
A transform() 0 5 1
1
<?php
2
3
namespace BiiiiiigMonster\LaravelEnum\Concerns;
4
5
abstract class Meta
6
{
7
    final public function __construct(
8
        public mixed $value,
9
    ) {
10
        $this->value = $this->transform($value);
11
    }
12
13
    public static function make(mixed $value): static
14
    {
15
        return new static($value);
16
    }
17
18
    protected function transform(mixed $value): mixed
19
    {
20
        // Feel free to override this to transform the value during instantiation
21
22
        return $value;
23
    }
24
25
    final public static function method(): string
26
    {
27
        if (property_exists(static::class, 'alias')) {
28
            return static::${'alias'};
29
        }
30
31
        return str(static::class)->classBasename()->lcfirst();
32
    }
33
}
34