Passed
Push — dev ( eeaa0f...91a85a )
by Janko
26:10
created

EventStrategyFactory::createEventStrategy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 44
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 35
nc 1
nop 1
dl 0
loc 44
ccs 0
cts 43
cp 0
crap 2
rs 9.36
c 0
b 0
f 0
1
<?php
2
3
namespace Stu\Component\Event\Strategy;
4
5
use JsonMapper\JsonMapperInterface;
6
use Stu\Component\Anomaly\AnomalyHandlingInterface;
7
use Stu\Component\Colony\ColonyFunctionManagerInterface;
8
use Stu\Component\Colony\Storage\ColonyStorageManagerInterface;
9
use Stu\Component\Event\EventTypeEnum;
10
use Stu\Module\Message\Lib\PrivateMessageSenderInterface;
11
use Stu\Module\Ship\Lib\Battle\AlertDetection\AlertDetectionInterface;
12
use Stu\Module\Ship\Lib\Battle\AlertDetection\AlertReactionFacadeInterface;
13
use Stu\Module\Ship\Lib\ShipWrapperFactoryInterface;
14
use Stu\Module\Tick\Npc\NoOneTick;
15
use Stu\Module\Tick\Npc\NpcTick;
16
use Stu\Module\Tick\Ship\ManagerComponent\LowerHull;
17
use Stu\Module\Tick\Ship\ManagerComponent\NpcShipHandling;
18
use Stu\Module\Tick\Ship\ManagerComponent\RepairActions;
19
use Stu\Module\Tick\User\UserTick;
20
use Stu\Orm\Repository\AnomalyRepositoryInterface;
21
use Stu\Orm\Repository\ColonyShipRepairRepositoryInterface;
22
use Stu\Orm\Repository\ModuleQueueRepositoryInterface;
23
use Stu\Orm\Repository\ShipRepositoryInterface;
24
use Stu\Orm\Repository\StationShipRepairRepositoryInterface;
25
use Stu\Orm\Repository\UserRepositoryInterface;
26
27
class EventStrategyFactory implements EventStrategyFactoryInterface
28
{
29
    public function __construct(
30
        private ShipRepositoryInterface $shipRepository,
31
        private AnomalyRepositoryInterface $anomalyRepository,
32
        private ColonyShipRepairRepositoryInterface $colonyShipRepairRepository,
33
        private StationShipRepairRepositoryInterface $stationShipRepairRepository,
34
        private UserRepositoryInterface $userRepository,
35
        private ModuleQueueRepositoryInterface $moduleQueueRepository,
36
        private AlertDetectionInterface $alertDetection,
37
        private AlertReactionFacadeInterface $alertReactionFacade,
38
        private AnomalyHandlingInterface $anomalyHandling,
39
        private NpcShipHandling $npcShipHandling,
40
        private ColonyFunctionManagerInterface $colonyFunctionManager,
41
        private ColonyStorageManagerInterface $colonyStorageManager,
42
        private ShipWrapperFactoryInterface $shipWrapperFactory,
43
        private RepairActions $repairActions,
44
        private LowerHull $lowerHull,
45
        private PrivateMessageSenderInterface $privateMessageSender,
46
        private JsonMapperInterface $jsonMapper,
47
        private UserTick $userTick
48
    ) {
49
    }
50
    public function createEventStrategy(EventTypeEnum $type): EventStrategyInterface
51
    {
52
        return match ($type) {
53
            EventTypeEnum::ALERT_REACTION => new AlertReactionEventStrategy(
54
                $this->shipRepository,
55
                $this->alertDetection,
56
                $this->alertReactionFacade,
57
                $this->shipWrapperFactory,
58
                $this->jsonMapper
59
            ),
60
            EventTypeEnum::ANOMALY_PROCESSING => new AnomalyProcessingEventStrategy(
61
                $this->anomalyRepository,
62
                $this->anomalyHandling,
63
                $this->jsonMapper
64
            ),
65
            EventTypeEnum::SPARE_PART_GENERATION => new SparePartGenerationEventStrategy(
66
                $this->moduleQueueRepository,
67
                $this->colonyFunctionManager,
68
                $this->colonyStorageManager,
69
                $this->privateMessageSender
70
            ),
71
            EventTypeEnum::COLONY_SHIP_REPAIR => new ColonyShipRepairEventStrategy(
72
                $this->colonyShipRepairRepository,
73
                $this->repairActions,
74
                $this->jsonMapper
75
            ),
76
            EventTypeEnum::STATION_SHIP_REPAIR => new StationShipRepairEventStrategy(
77
                $this->stationShipRepairRepository,
78
                $this->repairActions,
79
                $this->jsonMapper
80
            ),
81
            EventTypeEnum::USER_TICK => $this->userTick,
82
            EventTypeEnum::NPC_TICK => new NpcTick(
83
                $this->userRepository,
84
                $this->jsonMapper,
85
                $this->npcShipHandling
86
            ),
87
            EventTypeEnum::NOONE_TICK => new NoOneTick(
88
                $this->userRepository,
89
                $this->jsonMapper,
90
                $this->lowerHull
91
            ),
92
            EventTypeEnum::ANOMALY_CREATION => new AnomalyCreationEventStrategy(
93
                $this->anomalyHandling
94
            )
95
        };
96
    }
97
}
98