Passed
Push — dev ( 5010f4...52d0f1 )
by Janko
07:47
created

StationUiFactory::createDockingPrivilegeItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
ccs 7
cts 7
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Station\Lib;
6
7
use Stu\Component\Map\EncodedMapInterface;
8
use Stu\Lib\Map\VisualPanel\SystemScanPanelEntry;
9
use Stu\Lib\Map\VisualPanel\VisualPanelEntryData;
10
use Stu\Module\Logging\LoggerUtilInterface;
11
use Stu\Orm\Entity\DockingPrivilegeInterface;
12
use Stu\Orm\Entity\ShipInterface;
13
use Stu\Orm\Entity\StarSystemInterface;
14
use Stu\Orm\Entity\UserInterface;
15
use Stu\Orm\Repository\AllianceRepositoryInterface;
16
use Stu\Orm\Repository\FactionRepositoryInterface;
17
use Stu\Orm\Repository\ShipRepositoryInterface;
18
use Stu\Orm\Repository\UserRepositoryInterface;
19
20
/**
21
 * Creates ui and station related items
22
 */
23
final class StationUiFactory implements StationUiFactoryInterface
24
{
25
    private UserRepositoryInterface $userRepository;
26
27
    private AllianceRepositoryInterface $allianceRepository;
28
29
    private FactionRepositoryInterface $factionRepository;
30
31
    private ShipRepositoryInterface $shipRepository;
32
33
    private EncodedMapInterface $encodedMap;
34
35 1
    public function __construct(
36
        UserRepositoryInterface $userRepository,
37
        AllianceRepositoryInterface $allianceRepository,
38
        FactionRepositoryInterface $factionRepository,
39
        ShipRepositoryInterface $shipRepository,
40
        EncodedMapInterface $encodedMap
41
    ) {
42 1
        $this->userRepository = $userRepository;
43 1
        $this->allianceRepository = $allianceRepository;
44 1
        $this->factionRepository = $factionRepository;
45 1
        $this->shipRepository = $shipRepository;
46 1
        $this->encodedMap = $encodedMap;
47
    }
48
49
    public function createSystemScanPanel(
50
        ShipInterface $currentShip,
51
        UserInterface $user,
52
        LoggerUtilInterface $loggerUtil,
53
        StarSystemInterface $system
54
    ): SystemScanPanel {
55
        return new SystemScanPanel(
56
            $this,
57
            $this->shipRepository,
58
            $currentShip,
59
            $system,
60
            $user,
61
            $loggerUtil
62
        );
63
    }
64
65
    public function createSystemScanPanelEntry(
66
        VisualPanelEntryData $data,
67
        StarSystemInterface $system,
68
    ): SystemScanPanelEntry {
69
        return new SystemScanPanelEntry(
70
            $data,
71
            $this->encodedMap,
72
            $system
73
        );
74
    }
75
76 1
    public function createDockingPrivilegeItem(
77
        DockingPrivilegeInterface $dockingPrivilege
78
    ): DockingPrivilegeItem {
79 1
        return new DockingPrivilegeItem(
80 1
            $this->userRepository,
81 1
            $this->allianceRepository,
82 1
            $this->factionRepository,
83 1
            $this->shipRepository,
84 1
            $dockingPrivilege
85 1
        );
86
    }
87
}
88