Total Complexity | 7 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 10.53% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | final class TalentCollection extends Collection |
||
15 | { |
||
16 | public function findWeaponMasteryForWeaponType(WeaponType $weaponType): ?WeaponMastery |
||
17 | { |
||
18 | return $this->filter( |
||
19 | static fn(Talent $talent): bool => |
||
20 | $talent instanceof WeaponMastery && $talent->getType()->equals($weaponType), |
||
21 | )->getIterator()->current(); |
||
22 | } |
||
23 | |||
24 | public function findSecretKnowledge(): ?SecretKnowledge |
||
25 | { |
||
26 | return $this->filter( |
||
27 | static fn(Talent $talent): bool => $talent instanceof SecretKnowledge, |
||
28 | )->getIterator()->current(); |
||
29 | } |
||
30 | |||
31 | public function filterAttacks(): self |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | public function randomAttack(): Attack |
||
39 | { |
||
40 | $attacks = $this->filterAttacks(); |
||
41 | if ($attacks->isEmpty()) { |
||
42 | throw CollectionException::emptyCollection(); |
||
43 | } |
||
44 | |||
45 | return $attacks->getItems()[array_rand($attacks->getItems())]; |
||
46 | } |
||
47 | |||
48 | 1 | protected function getType(): string |
|
51 | } |
||
52 | } |
||
53 |