Passed
Pull Request — dev (#2303)
by Janko
05:56
created

BussardCollectorSystemSettings   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 33
ccs 12
cts 18
cp 0.6667
rs 10
wmc 4

2 Methods

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