Passed
Push — master ( 55cfd1...cb4d54 )
by Nico
22:41
created

SystemScanPanel::loadLSS()   B

Complexity

Conditions 8
Paths 64

Size

Total Lines 46
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 72

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 25
nc 64
nop 0
dl 0
loc 46
ccs 0
cts 27
cp 0
crap 72
rs 8.4444
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A SystemScanPanel::getEntryCallable() 0 7 1
A SystemScanPanel::getPanelViewportPercentage() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Station\Lib;
6
7
use Stu\Lib\Map\VisualPanel\AbstractVisualPanel;
8
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Shipcount\ShipcountLayerTypeEnum;
9
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceLayerTypeEnum;
10
use Stu\Lib\Map\VisualPanel\Layer\PanelLayerCreationInterface;
11
use Stu\Lib\Map\VisualPanel\PanelBoundaries;
12
use Stu\Lib\Map\VisualPanel\SystemScanPanelEntry;
13
use Stu\Module\Logging\LoggerUtilInterface;
14
use Stu\Orm\Entity\ShipInterface;
15
use Stu\Orm\Entity\StarSystemInterface;
16
use Stu\Orm\Entity\UserInterface;
17
18
class SystemScanPanel extends AbstractVisualPanel
19
{
20
    private ShipInterface $currentShip;
21
22
    private UserInterface $user;
23
24
    private StarSystemInterface $system;
25
26
    public function __construct(
27
        PanelLayerCreationInterface $panelLayerCreation,
28
        ShipInterface $currentShip,
29
        StarSystemInterface $system,
30
        UserInterface $user,
31
        LoggerUtilInterface $loggerUtil
32
    ) {
33
        parent::__construct($panelLayerCreation, $loggerUtil);
34
35
        $this->currentShip = $currentShip;
36
        $this->system = $system;
37
        $this->user = $user;
38
    }
39
40
    protected function createBoundaries(): PanelBoundaries
41
    {
42
        return PanelBoundaries::fromSystem($this->system);
43
    }
44
45
    protected function loadLayers(): void
46
    {
47
        $panelLayerCreation = $this->panelLayerCreation
48
            ->addShipCountLayer($this->currentShip->getTachyonState(), null, ShipcountLayerTypeEnum::ALL, 0)
49
            ->addBorderLayer($this->currentShip, $this->system === $this->currentShip->getSystem());
50
51
        $panelLayerCreation
52
            ->addSystemLayer()
53
            ->addColonyShieldLayer();
54
55
        if ($this->currentShip->getSubspaceState()) {
56
            $panelLayerCreation->addSubspaceLayer($this->user->getId(), SubspaceLayerTypeEnum::IGNORE_USER);
57
        }
58
59
        $this->layers = $panelLayerCreation->build($this);
60
    }
61
62
    protected function getEntryCallable(): callable
63
    {
64
        return fn (int $x, int $y) => new SystemScanPanelEntry(
65
            $x,
66
            $y,
67
            $this->layers,
68
            $this->system,
69
        );
70
    }
71
72
    protected function getPanelViewportPercentage(): int
73
    {
74
        return 33;
75
    }
76
}
77