Passed
Push — master ( f05eff...e96706 )
by Paweł
02:59
created

TalentCollection::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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\Inventory\Weapon\WeaponType;
10
use AardsGerds\Game\Shared\Collection;
11
12
final class TalentCollection extends Collection
13
{
14
    public function findWeaponMasteryForWeaponType(WeaponType $weaponType): ?WeaponMastery
15
    {
16
        return $this->filter(
17
            static fn(Talent $talent): bool =>
18
                $talent instanceof WeaponMastery && $talent->getType()->equals($weaponType),
19
        )->getIterator()->current();
20
    }
21
22
    public function findSecretKnowledge(): ?SecretKnowledge
23
    {
24
        return $this->filter(
25
            static fn(Talent $talent): bool => $talent instanceof SecretKnowledge,
26
        )->getIterator()->current();
27
    }
28
29
    protected function getType(): string
30
    {
31
        return Talent::class;
32
    }
33
}
34