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

ComponentSetup::setup()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 3
eloc 4
c 1
b 1
f 0
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 5
cp 0.8
crap 3.072
rs 10
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