Passed
Pull Request — master (#56)
by Brent
01:34
created

EnumDefinition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A equals() 0 4 2
1
<?php
2
3
namespace Spatie\Enum;
4
5
class EnumDefinition
6
{
7
    /** @var mixed */
8
    public $value;
9
10
    public string $label;
11
12
    private string $methodName;
13
14
    /**
15
     * @param string $methodName
16
     * @param mixed $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
        return $this->value === $input
29
            || $this->methodName === strtolower($input);
30
    }
31
}
32