Meta::method()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
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