Passed
Push — master ( 4cbcfa...1ee8de )
by Nico
53:18 queued 29:25
created

FleetWrapper::isForeignFleet()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\Lib;
6
7
use Stu\Module\Control\GameControllerInterface;
8
use Stu\Orm\Entity\FleetInterface;
9
10
final class FleetWrapper implements FleetWrapperInterface
11
{
12
    private FleetInterface $fleet;
13
14
    private ShipWrapperFactoryInterface $shipWrapperFactory;
15
16
    private GameControllerInterface $game;
17
18
    private bool $isSingleShips;
19
20 2
    public function __construct(
21
        FleetInterface $fleet,
22
        ShipWrapperFactoryInterface $shipWrapperFactory,
23
        GameControllerInterface $game,
24
        bool $isSingleShips
25
    ) {
26 2
        $this->fleet = $fleet;
27 2
        $this->shipWrapperFactory = $shipWrapperFactory;
28 2
        $this->game = $game;
29 2
        $this->isSingleShips = $isSingleShips;
30
    }
31
32 2
    public function get(): FleetInterface
33
    {
34 2
        return $this->fleet;
35
    }
36
37
    public function getLeadWrapper(): ShipWrapperInterface
38
    {
39
        return $this->shipWrapperFactory->wrapShip($this->get()->getLeadShip());
40
    }
41
42 2
    public function getShipWrappers(): array
43
    {
44 2
        return $this->shipWrapperFactory->wrapShips($this->get()->getShips()->toArray());
45
    }
46
47
    public function isForeignFleet(): bool
48
    {
49
        return !$this->isSingleShips && $this->get()->getUser() !== $this->game->getUser();
50
    }
51
}
52