WeaponType   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 9
c 1
b 0
f 0
dl 0
loc 33
ccs 10
cts 12
cp 0.8333
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A bow() 0 3 1
A shortSword() 0 3 1
A __construct() 0 3 1
A greatSword() 0 3 1
A __toString() 0 3 1
A equals() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Inventory\Weapon;
6
7
final class WeaponType implements \Stringable
8
{
9
    public const SHORT_SWORD = 'Short Sword';
10
    public const GREAT_SWORD = 'Great Sword';
11
    public const BOW = 'Bow';
12
13 6
    public function __construct(
14
        private string $type,
15 6
    ) {}
16
17 4
    public static function shortSword(): self
18
    {
19 4
        return new self(self::SHORT_SWORD);
20
    }
21
22 6
    public static function greatSword(): self
23
    {
24 6
        return new self(self::GREAT_SWORD);
25
    }
26
27
    public static function bow(): self
28
    {
29
        return new self(self::BOW);
30
    }
31
32 4
    public function equals(self $type): bool
33
    {
34 4
        return $this->type === (string) $type;
35
    }
36
37 5
    public function __toString(): string
38
    {
39 5
        return $this->type;
40
    }
41
}
42