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

IncomingBattleParty   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A initMembers() 0 14 3
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