Passed
Push — master ( 02b349...362dfe )
by Janko
10:06
created

TractorConsequence::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 3
dl 0
loc 5
ccs 2
cts 2
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\Ship\Lib\Movement\Component\Consequence\Flight;
6
7
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Stu\Component\Ship\System\Utility\TractorMassPayloadUtilInterface;
9
use Stu\Module\Ship\Lib\CancelColonyBlockOrDefendInterface;
10
use Stu\Module\Ship\Lib\Message\MessageCollectionInterface;
11
use Stu\Module\Ship\Lib\Message\MessageFactoryInterface;
12
use Stu\Module\Ship\Lib\Movement\Component\Consequence\AbstractFlightConsequence;
13
use Stu\Module\Ship\Lib\Movement\Route\FlightRouteInterface;
14
use Stu\Module\Ship\Lib\ShipWrapperInterface;
15
16
class TractorConsequence extends AbstractFlightConsequence
17
{
18 4
    public function __construct(
19
        private TractorMassPayloadUtilInterface $tractorMassPayloadUtil,
20
        private CancelColonyBlockOrDefendInterface $cancelColonyBlockOrDefend,
21
        private MessageFactoryInterface $messageFactory
22 4
    ) {}
23
24 2
    #[Override]
25
    protected function triggerSpecific(
26
        ShipWrapperInterface $wrapper,
27
        FlightRouteInterface $flightRoute,
28
        MessageCollectionInterface $messages
29
    ): void {
30
31 2
        $ship = $wrapper->get();
32
33 2
        $tractoredShip = $ship->getTractoredShip();
34 2
        if ($tractoredShip === null) {
35
            return;
36
        }
37
38 2
        $message = $this->messageFactory->createMessage();
39 2
        $messages->add($message);
40
41
        //can tow tractored ship?
42 2
        $canTowTractoredShip = $this->tractorMassPayloadUtil->tryToTow($wrapper, $tractoredShip, $message);
43 2
        if ($canTowTractoredShip) {
44 1
            $this->cancelColonyBlockOrDefend->work($ship, $message, true);
45
        }
46
    }
47
}
48