Passed
Push — dev ( 5e4699...833b4f )
by Nico
11:53
created

ShowWasteMenu::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
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 1
dl 0
loc 3
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\Spacecraft\View\ShowWasteMenu;
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 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 VIEW_IDENTIFIER = 'SHOW_WASTEMENU';
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
}