Passed
Pull Request — master (#13)
by Mostafa
11:05
created

CacheEnum   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A __callStatic() 0 3 1
A equals() 0 3 2
A getValue() 0 3 1
1
<?php
2
3
namespace Mostafaznv\LaraCache\Utils;
4
5
abstract class CacheEnum
6
{
7
    public function __construct(protected int|string $value) {}
8
9
    public static function __callStatic(string $name, array $arguments): self
10
    {
11
        return new static($name);
12
    }
13
14
    public function getValue(): int|string
15
    {
16
        return $this->value;
17
    }
18
19
    public function equals(self $other): bool
20
    {
21
        return get_class($this) === get_class($other) and $this->getValue() === $other->getValue();
22
    }
23
}
24