Test Failed
Push — master ( 6288df...4d55dd )
by Nico
33:49 queued 25:51
created

FleetWarpSplit::performSessionCheck()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\Action\FleetWarpSplit;
6
7
use request;
8
use Stu\Module\Control\ActionControllerInterface;
9
use Stu\Module\Control\GameControllerInterface;
10
use Stu\Module\Ship\Lib\ActivatorDeactivatorHelperInterface;
11
use Stu\Module\Ship\Lib\ShipLoaderInterface;
12
use Stu\Module\Ship\View\ShowShip\ShowShip;
13
14
15
final class FleetWarpSplit implements ActionControllerInterface
16
{
17
    public const ACTION_IDENTIFIER = 'B_FLEET_WARP_SPLIT';
18
19
    private ActivatorDeactivatorHelperInterface $helper;
20
21
    private ShipLoaderInterface $shipLoader;
22
23
    public function __construct(
24
        ActivatorDeactivatorHelperInterface $helper,
25
        ShipLoaderInterface $shipLoader
26
    ) {
27
        $this->helper = $helper;
28
        $this->shipLoader = $shipLoader;
29
    }
30
31
    public function handle(GameControllerInterface $game): void
32
    {
33
        $this->helper->setWarpSplitFleet(request::indInt('id'), $game);
34
35
        $userId = $game->getUser()->getId();
36
37
        $ship = $this->shipLoader->getByIdAndUser(
38
            request::indInt('id'),
39
            $userId
40
        );
41
42
        if ($ship->isDestroyed()) {
43
            return;
44
        }
45
46
        $game->setView(ShowShip::VIEW_IDENTIFIER);
47
    }
48
49
    public function performSessionCheck(): bool
50
    {
51
        return true;
52
    }
53
}
54