Passed
Push — master ( c7bbda...2af45c )
by Nico
24:27 queued 11:28
created

ColonyGuiHelper::registerComponents()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 3
dl 0
loc 8
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Colony\Lib\Gui;
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 Stu\Component\Colony\ColonyMenuEnum;
9
use Stu\Lib\Colony\PlanetFieldHostInterface;
10
use Stu\Lib\Component\ComponentRegistrationInterface;
11
use Stu\Module\Control\GameControllerInterface;
12
use Stu\Orm\Entity\ColonySandboxInterface;
13
14
final class ColonyGuiHelper implements ColonyGuiHelperInterface
15
{
16 1
    public function __construct(private ComponentRegistrationInterface $componentRegistration) {}
17
18 18
    #[Override]
19
    public function registerMenuComponents(
20
        ColonyMenuEnum $menu,
21
        PlanetFieldHostInterface $host,
22
        GameControllerInterface $game
23
    ): void {
24
25 18
        foreach ($menu->getNecessaryGuiComponents() as $componentEnum) {
26 16
            $this->componentRegistration->registerComponent($componentEnum, $host);
27
        }
28
29 18
        $game->setTemplateVar('HOST', $host);
30 18
        $game->setTemplateVar('CURRENT_MENU', $menu);
31
32 18
        if ($host instanceof ColonySandboxInterface) {
33
            $game->setTemplateVar('COLONY', $host->getColony());
34
        } else {
35 18
            $game->setTemplateVar('COLONY', $host);
36
        }
37
    }
38
39 1
    #[Override]
40
    public function registerComponents(
41
        PlanetFieldHostInterface $host,
42
        GameControllerInterface $game,
43
        array $guiComponents
44
    ): void {
45 1
        foreach ($guiComponents as $componentEnum) {
46 1
            $this->componentRegistration->registerComponent($componentEnum, $host);
47
        }
48
    }
49
}
50