Passed
Pull Request — master (#1819)
by Nico
52:14 queued 25:19
created

ColonyDefendingBattleParty   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAlertDescription() 0 3 1
A getAttackCause() 0 3 1
A initMembers() 0 11 2
1
<?php
2
3
namespace Stu\Module\Ship\Lib\Battle\Party;
4
5
use Doctrine\Common\Collections\Collection;
6
use Stu\Module\Ship\Lib\Battle\ShipAttackCauseEnum;
7
use Stu\Module\Ship\Lib\ShipWrapperInterface;
8
9
class ColonyDefendingBattleParty extends AbstractBattleParty implements AlertedBattlePartyInterface
10
{
11 4
    public function __construct(
12
        ShipWrapperInterface $leader
13
    ) {
14 4
        parent::__construct($leader);
15
    }
16
17 2
    public function initMembers(): Collection
18
    {
19 2
        $fleet = $this->leader->getFleetWrapper();
20
21 2
        if ($fleet === null) {
22 1
            return $this->createSingleton($this->leader);
23
        } else {
24
25
            // only uncloaked ships enter fight
26 1
            return $fleet->getShipWrappers()
27 1
                ->filter(fn (ShipWrapperInterface $wrapper) => !$wrapper->get()->getCloakState());
28
        }
29
    }
30
31 1
    public function getAttackCause(): ShipAttackCauseEnum
32
    {
33 1
        return ShipAttackCauseEnum::COLONY_DEFENSE;
34
    }
35
36 1
    public function getAlertDescription(): string
37
    {
38 1
        return '[b][color=orange]Kolonie-Verteidigung[/color][/b]';
39
    }
40
}
41