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

AttackingBattleParty   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initMembers() 0 13 4
A __construct() 0 6 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\FleetWrapperInterface;
7
use Stu\Module\Ship\Lib\ShipWrapperInterface;
8
9
class AttackingBattleParty extends AbstractBattleParty
10
{
11 4
    public function __construct(
12
        private ShipWrapperInterface|FleetWrapperInterface $wrapper
13
    ) {
14 4
        $leader = $wrapper instanceof ShipWrapperInterface ? $wrapper : $wrapper->getLeadWrapper();
15
16 4
        parent::__construct($leader);
17
    }
18
19 4
    public function initMembers(): Collection
20
    {
21 4
        if ($this->wrapper instanceof FleetWrapperInterface) {
22 1
            return $this->wrapper->getShipWrappers();
23
        }
24
25 3
        $ship = $this->wrapper->get();
26 3
        $fleetWrapper = $this->wrapper->getFleetWrapper();
27
28 3
        if ($ship->isFleetLeader() && $fleetWrapper !== null) {
29 1
            return $fleetWrapper->getShipWrappers();
30
        } else {
31 2
            return $this->createSingleton($this->wrapper);
32
        }
33
    }
34
}
35