Passed
Push — master ( 947512...97c1fb )
by Paweł
03:48
created

Ascension   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 29
c 1
b 0
f 0
dl 0
loc 70
ccs 0
cts 30
cp 0
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A seventhAscension() 0 3 1
A sixthAscension() 0 3 1
A validate() 0 4 2
A firstAscension() 0 3 1
A eighthAscension() 0 3 1
A thirdAscension() 0 3 1
A fifthAscension() 0 3 1
A __toString() 0 12 1
A fourthAscension() 0 3 1
A secondAscension() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Build\Talent\SecretKnowledge;
6
7
use AardsGerds\Game\Shared\IntegerValue;
8
use AardsGerds\Game\Shared\IntegerValueException;
9
10
final class Ascension extends IntegerValue
11
{
12
    public const FIRST_ASCENSION = 1;
13
    public const SECOND_ASCENSION = 2;
14
    public const THIRD_ASCENSION = 3;
15
    public const FOURTH_ASCENSION = 4;
16
    public const FIFTH_ASCENSION = 5;
17
    public const SIXTH_ASCENSION = 6;
18
    public const SEVENTH_ASCENSION = 7;
19
    public const EIGHTH_ASCENSION = 8;
20
21
    public static function firstAscension(): self
22
    {
23
        return new self(self::FIRST_ASCENSION);
24
    }
25
26
    public static function secondAscension(): self
27
    {
28
        return new self(self::SECOND_ASCENSION);
29
    }
30
31
    public static function thirdAscension(): self
32
    {
33
        return new self(self::THIRD_ASCENSION);
34
    }
35
36
    public static function fourthAscension(): self
37
    {
38
        return new self(self::FOURTH_ASCENSION);
39
    }
40
41
    public static function fifthAscension(): self
42
    {
43
        return new self(self::FIFTH_ASCENSION);
44
    }
45
46
    public static function sixthAscension(): self
47
    {
48
        return new self(self::SIXTH_ASCENSION);
49
    }
50
51
    public static function seventhAscension(): self
52
    {
53
        return new self(self::SEVENTH_ASCENSION);
54
    }
55
56
    public static function eighthAscension(): self
57
    {
58
        return new self(self::EIGHTH_ASCENSION);
59
    }
60
61
    public function __toString(): string
62
    {
63
        return match ($this->value) {
64
            self::FIRST_ASCENSION => 'First Ascension',
65
            self::SECOND_ASCENSION => 'Second Ascension',
66
            self::THIRD_ASCENSION => 'Third Ascension',
67
            self::FOURTH_ASCENSION => 'Fourth Ascension',
68
            self::FIFTH_ASCENSION => 'Fifth Ascension',
69
            self::SIXTH_ASCENSION => 'Sixth Ascension',
70
            self::SEVENTH_ASCENSION => 'Seventh Ascension',
71
            self::EIGHTH_ASCENSION => 'Eighth Ascension',
72
            default => throw IntegerValueException::invalidValue($this->value),
73
        };
74
    }
75
76
    protected function validate(): void
77
    {
78
        if (!in_array($this->value, range(self::FIRST_ASCENSION, self::EIGHTH_ASCENSION))) {
79
            throw IntegerValueException::invalidValue($this->value);
80
        }
81
    }
82
}
83