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

TalentCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 20
ccs 0
cts 11
cp 0
rs 10
c 2
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 3 1
A findSecretKnowledge() 0 5 1
A findWeaponMasteryForWeaponType() 0 6 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