Passed
Push — master ( fa53c0...9478ec )
by Paweł
02:37
created

WeaponMastery   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 10
c 3
b 0
f 0
dl 0
loc 50
ccs 10
cts 20
cp 0.5
rs 10
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A bow() 0 3 1
A getRequiredTalentPoints() 0 3 1
A getDescription() 0 3 1
A __toString() 0 3 1
A greatSword() 0 3 1
A shortSword() 0 3 1
A getLevel() 0 3 1
A __construct() 0 4 1
A getType() 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
11
final class WeaponMastery implements Talent, \Stringable
12
{
13 1
    private function __construct(
14
        private WeaponType $type,
15
        private WeaponMasteryLevel $level,
16 1
    ) {}
17
18 1
    public static function shortSword(WeaponMasteryLevel $level): self
19
    {
20 1
        return new self(WeaponType::shortSword(), $level);
21
    }
22
23 1
    public static function greatSword(WeaponMasteryLevel $level): self
24
    {
25 1
        return new self(WeaponType::greatSword(), $level);
26
    }
27
28
    public static function bow(WeaponMasteryLevel $level): self
29
    {
30
        return new self(WeaponType::bow(), $level);
31
    }
32
33
    public static function getName(): string
34
    {
35
        return 'Weapon Mastery';
36
    }
37
38
    public static function getDescription(): string
39
    {
40
        return 'Talent of weapon fighting.';
41
    }
42
43
    public static function getRequiredTalentPoints(): TalentPoints
44
    {
45
        return new TalentPoints(4);
46
    }
47
48 1
    public function getType(): WeaponType
49
    {
50 1
        return $this->type;
51
    }
52
53 1
    public function getLevel(): WeaponMasteryLevel
54
    {
55 1
        return $this->level;
56
    }
57
58
    public function __toString(): string
59
    {
60
        return "Mastery at {$this->type}: {$this->level}";
61
    }
62
}