Passed
Push — dev ( 8e4f3d...84d979 )
by Janko
29:51
created

ComponentSetup   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 5
c 1
b 1
f 0
dl 0
loc 16
ccs 6
cts 7
cp 0.8571
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 8 3
A __construct() 0 5 1
1
<?php
2
3
namespace Stu\Module\Control;
4
5
use Stu\Lib\Component\ComponentLoaderInterface;
6
use Stu\Lib\Component\ComponentRegistrationInterface;
7
use Stu\Module\Game\Component\GameComponentEnum;
8
use Stu\Orm\Repository\PrivateMessageRepositoryInterface;
9
10
class ComponentSetup implements ComponentSetupInterface
11
{
12 2
    public function __construct(
13
        private PrivateMessageRepositoryInterface $privateMessageRepository,
14
        private ComponentRegistrationInterface $componentRegistration,
15
        private ComponentLoaderInterface $componentLoader
16 2
    ) {}
17
18 184
    public function setup(GameControllerInterface $game): void
19
    {
20 184
        if ($game->hasUser() && $this->privateMessageRepository->hasRecentMessage($game->getUser())) {
21
            $this->componentRegistration->addComponentUpdate(GameComponentEnum::PM);
22
        }
23
24 184
        $this->componentLoader->loadComponentUpdates($game);
25 184
        $this->componentLoader->loadRegisteredComponents($game);
26
    }
27
}
28