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

ShipcountDataProviderFactory::getDataProvider()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 5
nop 2
dl 0
loc 15
ccs 0
cts 10
cp 0
crap 30
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\Map\VisualPanel\Layer\DataProvider\Shipcount;
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 ShipcountDataProviderFactory implements ShipcountDataProviderFactoryInterface
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, ShipcountLayerTypeEnum $type): AbstractPanelLayerDataProvider
25
    {
26
        switch ($type) {
27
            case ShipcountLayerTypeEnum::ALL:
28
                return new GeneralShipcountDataProvider($this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
29
            case ShipcountLayerTypeEnum::ALLIANCE_ONLY:
30
                return new AllianceShipcountDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
31
            case ShipcountLayerTypeEnum::USER_ONLY:
32
                return new UserShipcountDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
33
            case ShipcountLayerTypeEnum::SHIP_ONLY:
34
                return new ShipShipcountDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository);
35
        }
36
37
        throw new RuntimeException(sprintf('Shipcount layer type %d is not supported', $type->value));
38
    }
39
}
40