Passed
Pull Request — master (#56)
by Brent
12:41
created

EnumDefinition::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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