Passed
Push — master ( 02b349...362dfe )
by Janko
10:06
created

SubspaceDataProviderFactory::getDataProvider()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
eloc 13
nc 6
nop 2
dl 0
loc 17
ccs 0
cts 12
cp 0
crap 42
rs 9.2222
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace;
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 RuntimeException;
9
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\AbstractPanelLayerDataProvider;
10
use Stu\Orm\Repository\LocationRepositoryInterface;
11
use Stu\Orm\Repository\MapRepositoryInterface;
12
use Stu\Orm\Repository\StarSystemMapRepositoryInterface;
13
14
final class SubspaceDataProviderFactory implements SubspaceDataProviderFactoryInterface
15
{
16 2
    public function __construct(
17
        private LocationRepositoryInterface $locationRepository,
18
        private MapRepositoryInterface $mapRepository,
19
        private StarSystemMapRepositoryInterface $starSystemMapRepository
20
    ) {
21 2
    }
22
23
    #[Override]
24
    public function getDataProvider(int $id, SubspaceLayerTypeEnum $type): AbstractPanelLayerDataProvider
25
    {
26
        switch ($type) {
27
            case SubspaceLayerTypeEnum::ALL:
28
                return new GeneralSubspaceDataProvider($this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
29
            case SubspaceLayerTypeEnum::IGNORE_USER:
30
                return new IgnoringSubspaceDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
31
            case SubspaceLayerTypeEnum::ALLIANCE_ONLY:
32
                return new AllianceSubspaceDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
33
            case SubspaceLayerTypeEnum::USER_ONLY:
34
                return new UserSubspaceDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
35
            case SubspaceLayerTypeEnum::SHIP_ONLY:
36
                return new ShipSubspaceDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
37
        }
38
39
        throw new RuntimeException(sprintf('subspace layer type %d is not supported', $type->value));
40
    }
41
}
42