Passed
Push — master ( 798624...f2c7f4 )
by Paweł
03:25
created

WeaponMastery::getLevel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Build\Talent\WeaponMastery;
6
7
use AardsGerds\Game\Build\Talent\Talent;
8
use AardsGerds\Game\Build\Talent\TalentPoints;
9
use AardsGerds\Game\Inventory\Weapon\WeaponType;
10
use JetBrains\PhpStorm\Immutable;
11
12
#[Immutable]
13 1
final class WeaponMastery implements Talent
14
{
15 1
    public function __construct(
16
        private WeaponType $type,
17
        private WeaponMasteryLevel $level,
18 1
    ) {}
19
20 1
    public static function shortSword(WeaponMasteryLevel $level): self
21
    {
22 1
        return new self(WeaponType::shortSword(), $level);
23
    }
24
25 1
    public static function greatSword(WeaponMasteryLevel $level): self
26
    {
27 1
        return new self(WeaponType::greatSword(), $level);
28
    }
29
30
    public static function bow(WeaponMasteryLevel $level): self
31
    {
32
        return new self(WeaponType::bow(), $level);
33
    }
34
35
    public static function getName(): string
36
    {
37
        return 'Weapon Mastery';
38
    }
39
40
    public static function getDescription(): string
41
    {
42
        return 'Talent of weapon fighting.';
43
    }
44
45
    public static function getRequiredTalentPoints(): TalentPoints
46
    {
47
        return new TalentPoints(4);
48
    }
49
50 1
    public function getType(): WeaponType
51
    {
52 1
        return $this->type;
53
    }
54
55 1
    public function getLevel(): WeaponMasteryLevel
56
    {
57 1
        return $this->level;
58
    }
59
60
    public function __toString(): string
61
    {
62
        return "Mastery at {$this->type}: {$this->level}";
63
    }
64
}
65