Passed
Pull Request — master (#7)
by Thijs
02:28
created

NodeType::MIN()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace lucidtaz\minimax\engine;
4
5
/**
6
 * Enum class
7
 */
8
class NodeType
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
9
{
10
    private $value;
11
12 13
    private function __construct()
13
    {
14
        // Forbid direct construction
15 13
    }
16
17 12
    public static function MIN(): NodeType
18
    {
19 12
        $result = new static();
20 12
        $result->value = 'min';
21 12
        return $result;
22
    }
23
24 13
    public static function MAX(): NodeType
25
    {
26 13
        $result = new static();
27 13
        $result->value = 'max';
28 13
        return $result;
29
    }
30
31 12
    public function alternate(): NodeType
32
    {
33 12
        if ($this == self::MIN()) {
34 11
            return self::MAX();
35
        }
36 12
        return self::MIN();
37
    }
38
}
39