Passed
Push — master ( c169de...dc3f23 )
by Paweł
03:09
created

WeaponMasteryLevel::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Build\Talent\WeaponMastery;
6
7
use AardsGerds\Game\Shared\IntegerValue;
8
9
final class WeaponMasteryLevel extends IntegerValue
10
{
11
    public const INEXPERIENCED = 0;
12
    public const NOVICE = 1;
13
    public const WARRIOR = 2;
14
    public const VETERAN = 3;
15
    public const MASTER_OF_FIRST_TIER = 4;
16
    public const MASTER_OF_SECOND_TIER = 5;
17
    public const MASTER_OF_THIRD_TIER = 6;
18
19
    private const STRING_VALUES = [
20
        self::INEXPERIENCED => 'inexperienced',
21
        self::NOVICE => 'novice',
22
        self::WARRIOR => 'warrior',
23
        self::VETERAN => 'veteran',
24
        self::MASTER_OF_FIRST_TIER => 'master of first tier',
25
        self::MASTER_OF_SECOND_TIER => 'master of second tier',
26
        self::MASTER_OF_THIRD_TIER => 'master of third tier',
27
    ];
28
29
    public static function inexperienced(): self
30
    {
31
        return new self(self::INEXPERIENCED);
32
    }
33
34
    public static function novice(): self
35
    {
36
        return new self(self::NOVICE);
37
    }
38
39
    public static function warrior(): self
40
    {
41
        return new self(self::WARRIOR);
42
    }
43
44
    public static function veteran(): self
45
    {
46
        return new self(self::VETERAN);
47
    }
48
49
    public static function masterOfFirstTier(): self
50
    {
51
        return new self(self::MASTER_OF_FIRST_TIER);
52
    }
53
54
    public static function masterOfSecondTier(): self
55
    {
56
        return new self(self::MASTER_OF_SECOND_TIER);
57
    }
58
59
    public static function masterOfThirdTier(): self
60
    {
61
        return new self(self::MASTER_OF_THIRD_TIER);
62
    }
63
64
    public function __toString(): string
65
    {
66
        return self::STRING_VALUES[$this->value];
67
    }
68
69
    private function __construct(int $value)
70
    {
71
        parent::__construct($value);
72
    }
73
}
74