Passed
Push — dev ( d85471...98511f )
by Janko
18:01
created

ShowWasteMenu   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 16.66%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 30
ccs 2
cts 12
cp 0.1666
rs 10
c 0
b 0
f 0
wmc 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Spacecraft\View\ShowWasteMenu;
6
7
use Override;
8
use request;
9
use Stu\Module\Control\GameControllerInterface;
10
use Stu\Module\Control\ViewContextTypeEnum;
11
use Stu\Module\Control\ViewControllerInterface;
12
use Stu\Module\Spacecraft\Lib\SpacecraftLoaderInterface;
13
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface;
14
15
16
final class ShowWasteMenu implements ViewControllerInterface
17
{
18
    public const string VIEW_IDENTIFIER = 'SHOW_WASTEMENU';
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 18 at column 24
Loading history...
19
20
    /**
21
     * @param SpacecraftLoaderInterface<SpacecraftWrapperInterface> $spaceCraftLoader
22
     */
23 1
    public function __construct(
24
        private SpacecraftLoaderInterface $spaceCraftLoader
25 1
    ) {}
26
27
    #[Override]
28
    public function handle(GameControllerInterface $game): void
29
    {
30
        $userId = $game->getUser()->getId();
31
32
        $spacecraft = $this->spaceCraftLoader->getByIdAndUser(request::getIntFatal('id'), $userId);
33
34
        if (!$game->getUser()->isNpc()) {
35
            return;
36
        }
37
38
        $game->setPageTitle(_('Müllverbrennung'));
39
        if ($game->getViewContext(ViewContextTypeEnum::NO_AJAX) === true) {
40
            $game->showMacro('html/spacecraft/waste.twig');
41
        } else {
42
            $game->setMacroInAjaxWindow('html/spacecraft/waste.twig');
43
        }
44
45
        $game->setTemplateVar('SPACECRAFT', $spacecraft);
46
    }
47
}