WeaponType::equals()   A
last analyzed

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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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