Passed
Push — dev ( 59981f...f2247e )
by Janko
47:08
created

IncomingBattleParty   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A initMembers() 0 17 4
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 3
    public function __construct(
12
        ShipWrapperInterface $leader
13
    ) {
14 3
        parent::__construct($leader);
15
    }
16
17 3
    public function initMembers(): Collection
18
    {
19 3
        $fleet = $this->leader->getFleetWrapper();
20 3
        if ($fleet === null) {
21
22
            // if flying ship is cloaked, nothing happens
23 2
            if ($this->leader->get()->getCloakState()) {
24 1
                return  new ArrayCollection();
25
            }
26
27 1
            return $this->createSingleton($this->leader);
28
        }
29
30
        // filter warped and cloaked
31 1
        return $fleet->getShipWrappers()
32 1
            ->filter(fn (ShipWrapperInterface $wrapper) => !$wrapper->get()->getCloakState()
33 1
                && !$wrapper->get()->isWarped());
34
    }
35
}
36