Passed
Push — dev ( 8c2a37...0c0b28 )
by Janko
49:23 queued 25:53
created

CallForSupportBehaviour::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Stu\Lib\Pirate\Behaviour;
4
5
use Stu\Module\Ship\Lib\FleetWrapperInterface;
6
use Stu\Lib\Pirate\PirateCreationInterface;
7
use Stu\Lib\Pirate\PirateReactionInterface;
8
use Stu\Lib\Pirate\PirateReactionTriggerEnum;
9
use Stu\Module\Logging\LoggerUtilFactoryInterface;
10
use Stu\Module\Logging\PirateLoggerInterface;
11
12
class CallForSupportBehaviour implements PirateBehaviourInterface
13
{
14
    private PirateCreationInterface $pirateCreation;
15
16
    private PirateLoggerInterface $logger;
17
18
    public function __construct(
19
        PirateCreationInterface $pirateCreation,
20
        LoggerUtilFactoryInterface $loggerUtilFactory
21
    ) {
22
        $this->pirateCreation = $pirateCreation;
23
24
        $this->logger = $loggerUtilFactory->getPirateLogger();
25
    }
26
27
    public function action(FleetWrapperInterface $fleet, PirateReactionInterface $pirateReaction): void
28
    {
29
        $leadWrapper = $fleet->getLeadWrapper();
30
        $leadShip = $leadWrapper->get();
31
32
        $supportFleet = $this->pirateCreation->createPirateFleet($leadShip);
33
34
        $this->logger->logf('created support fleet "%s" here %s', $supportFleet->getName(), $supportFleet->getLeadShip()->getSectorString());
35
36
        $pirateReaction->react(
37
            $supportFleet,
38
            PirateReactionTriggerEnum::ON_SUPPORT_CALL
39
        );
40
    }
41
}
42