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

WeaponMastery   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 52.38%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 10
eloc 11
c 4
b 0
f 0
dl 0
loc 51
ccs 11
cts 21
cp 0.5238
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A greatSword() 0 3 1
A shortSword() 0 3 1
A getLevel() 0 3 1
A getName() 0 3 1
A __construct() 0 4 1
A getRequiredTalentPoints() 0 3 1
A bow() 0 3 1
A getType() 0 3 1
A getDescription() 0 3 1
A __toString() 0 3 1
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