Passed
Pull Request — master (#2146)
by Janko
22:01 queued 11:32
created

PlayerSettingsProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 20
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setTemplateVariables() 0 14 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Game\Lib\View\Provider;
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\Player\Settings\UserSettingsProviderInterface;
9
use Stu\Module\Control\GameControllerInterface;
10
use Stu\Module\PlayerSetting\Lib\UserSettingEnum;
11
use Stu\Module\PlayerSetting\Lib\UserSettingWrapper;
12
13
final class PlayerSettingsProvider implements ViewComponentProviderInterface
14
{
15 1
    public function __construct(
16
        private readonly UserSettingsProviderInterface $userSettingsProvider
17 1
    ) {}
18
19 1
    #[Override]
20
    public function setTemplateVariables(GameControllerInterface $game): void
21
    {
22 1
        $user = $game->getUser();
23
24 1
        $game->appendNavigationPart(
25 1
            'options.php',
26 1
            _('Optionen')
27 1
        );
28
29 1
        $game->setTemplateVar('DISTINCT_SETTING_WRAPPERS', array_map(fn(UserSettingEnum $type): UserSettingWrapper => new UserSettingWrapper($user, $type, $game->isAdmin(), $this->userSettingsProvider), UserSettingEnum::getDistinct()));
30 1
        $game->setTemplateVar('SETTING_WRAPPERS', array_map(fn(UserSettingEnum $type): UserSettingWrapper => new UserSettingWrapper($user, $type, $game->isAdmin(), $this->userSettingsProvider), UserSettingEnum::getNonDistinct()));
31
32 1
        $game->setTemplateVar('REAL_USER', $user);
33
    }
34
}
35