Passed
Push — master ( 954430...fcf71b )
by Paweł
02:57
created

TalentCollection::getType()   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;
6
7
use AardsGerds\Game\Build\Talent\SecretKnowledge\SecretKnowledge;
8
use AardsGerds\Game\Build\Talent\WeaponMastery\WeaponMastery;
9
use AardsGerds\Game\Fight\Attack;
10
use AardsGerds\Game\Inventory\Weapon\WeaponType;
11
use AardsGerds\Game\Shared\Collection;
12
13
final class TalentCollection extends Collection
14
{
15
    public function findWeaponMasteryForWeaponType(WeaponType $weaponType): ?WeaponMastery
16
    {
17
        return $this->filter(
18
            static fn(Talent $talent): bool =>
19
                $talent instanceof WeaponMastery && $talent->getType()->equals($weaponType),
20
        )->getIterator()->current();
21
    }
22
23
    public function findSecretKnowledge(): ?SecretKnowledge
24
    {
25
        return $this->filter(
26
            static fn(Talent $talent): bool => $talent instanceof SecretKnowledge,
27
        )->getIterator()->current();
28
    }
29
30
    public function filterAttacks(): self
31
    {
32
        return $this->filter(
33
            static fn(Talent $talent): bool => $talent instanceof Attack,
34
        );
35
    }
36
37 1
    protected function getType(): string
38
    {
39 1
        return Talent::class;
40
    }
41
}
42