Ascension   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 12
eloc 39
c 1
b 0
f 0
dl 0
loc 85
ccs 41
cts 41
cp 1
rs 10

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