Passed
Pull Request — master (#1821)
by Nico
52:02 queued 25:23
created

IncomingBattleParty::initMembers()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 3
rs 10
1
<?php
2
3
namespace Stu\Module\Ship\Lib\Battle\Party;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Stu\Module\Ship\Lib\ShipWrapperInterface;
8
9
class IncomingBattleParty extends AbstractBattleParty
10
{
11 4
    public function __construct(
12
        ShipWrapperInterface $leader
13
    ) {
14 4
        parent::__construct($leader);
15
    }
16
17 4
    public function initMembers(): Collection
18
    {
19 4
        $fleet = $this->leader->getFleetWrapper();
20
21 4
        if ($fleet === null) {
22 3
            $result = $this->createSingleton($this->leader);
23
        } else {
24 1
            $result = $fleet->getShipWrappers();
25
        }
26
27
        // filter warped and cloaked
28 4
        return $result
29 4
            ->filter(fn (ShipWrapperInterface $wrapper) =>
30 4
            !$wrapper->get()->getCloakState() && !$wrapper->get()->isWarped());
31
    }
32
}
33