Passed
Push — dev ( 5e4699...833b4f )
by Nico
11:53
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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 19 3
A __construct() 0 3 1
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
}