Passed
Pull Request — master (#56)
by Brent
02:21
created

EnumDefinition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 3
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A equals() 0 11 3
1
<?php
2
3
namespace Spatie\Enum;
4
5
class EnumDefinition
6
{
7
    /** @var string|int */
8
    public $value;
9
10
    public string $label;
11
12
    private string $methodName;
13
14
    /**
15
     * @param string $methodName
16
     * @param string|int $value
17
     * @param string $label
18
     */
19
    public function __construct(string $methodName, $value, string $label)
20
    {
21
        $this->methodName = strtolower($methodName);
22
        $this->value = $value;
23
        $this->label = $label;
24
    }
25
26
    public function equals($input): bool
27
    {
28
        if ($this->value === $input) {
29
            return true;
30
        }
31
32
        if ($this->methodName === strtolower($input)) {
33
            return true;
34
        }
35
36
        return false;
37
    }
38
}
39