Passed
Push — dev ( 219c54...831a1f )
by Janko
08:28
created

ControllerDiscovery::getContainerIdentifier()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stu\Module\Control\Component;
4
5
use Stu\Component\Game\ModuleEnum;
6
use Stu\Config\Init;
7
use Stu\Module\Control\ControllerInterface;
8
9
class ControllerDiscovery implements ControllerDiscoveryInterface
10
{
11
    /**
12
     * @return array<string, ControllerInterface>
13
     */
14
    public function getControllers(ModuleEnum $module, bool $isViewController): array
15
    {
16
        $controllers = Init::getContainer()->get($this->getContainerIdentifier($module->name, $isViewController));
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Stu\Component\Game\ModuleEnum.
Loading history...
17
18
        $commonModule = $module->getCommonModule();
19
        if ($commonModule === null) {
20
            return $controllers;
21
        }
22
23
        return array_merge(Init::getContainer()->get($this->getContainerIdentifier($commonModule, $isViewController)), $controllers);
24
    }
25
26
    private function getContainerIdentifier(string $module, bool $isViewController): string
27
    {
28
        return sprintf(
29
            '%s_%s',
30
            $module,
31
            $isViewController ? 'VIEWS' : 'ACTIONS'
32
        );
33
    }
34
}
35