Passed
Pull Request — master (#2311)
by Nico
07:31 queued 02:09
created

BussardCollectorSystemSettings::__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\ShowSystemSettings;
6
7
use RuntimeException;
8
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
9
use Stu\Exception\SanityCheckException;
10
use Stu\Module\Control\GameControllerInterface;
11
use Stu\Module\Ship\Lib\ShipWrapperInterface;
12
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface;
13
use Stu\Orm\Repository\LocationMiningRepositoryInterface;
14
15
class BussardCollectorSystemSettings implements SystemSettingsProviderInterface
16
{
17 1
    public function __construct(
18
        private LocationMiningRepositoryInterface $locationMiningRepository
19 1
    ) {}
20
21 1
    #[\Override]
22
    public function setTemplateVariables(
23
        SpacecraftSystemTypeEnum $systemType,
24
        SpacecraftWrapperInterface $wrapper,
25
        GameControllerInterface $game
26
    ): void {
27 1
        if (!$wrapper instanceof ShipWrapperInterface) {
28
            throw new RuntimeException('this should not happen');
29
        }
30
31 1
        $ship = $wrapper->get();
32
33 1
        $game->setMacroInAjaxWindow('html/ship/bussardcollector.twig');
34
35 1
        $collector = $wrapper->getBussardCollectorSystemData();
36 1
        if ($collector === null) {
37
            throw new SanityCheckException(
38
                'no bussard collector installed',
39
                null,
40
                ShowSystemSettings::VIEW_IDENTIFIER
0 ignored issues
show
Bug introduced by
The type Stu\Module\Spacecraft\Vi...ings\ShowSystemSettings 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...
41
            );
42
        }
43
44 1
        $mining = $this->locationMiningRepository->getMiningAtLocation($ship);
45 1
        $miningqueue = $ship->getMiningQueue();
46 1
        $game->setTemplateVar('MINING', $mining);
47 1
        $game->setTemplateVar('MININGQUEUE', $miningqueue);
48
    }
49
}
50