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

NodeType   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 31
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A MIN() 0 6 1
A MAX() 0 6 1
A alternate() 0 7 2
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