Passed
Push — dev ( 91186a...20d5e2 )
by Janko
05:17
created

SubspaceDataProviderFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDataProvider() 0 9 1
A __construct() 0 6 1
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 Stu\Lib\Map\VisualPanel\Layer\DataProvider\AbstractPanelLayerDataProvider;
9
use Stu\Module\Control\StuTime;
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 readonly LocationRepositoryInterface $locationRepository,
18
        private readonly MapRepositoryInterface $mapRepository,
19
        private readonly StarSystemMapRepositoryInterface $starSystemMapRepository,
20
        private readonly StuTime $stuTime
21 2
    ) {}
22 1
    #[Override]
23
    public function getDataProvider(int $id, SubspaceLayerTypeEnum $type, ?int $rumpId = null): AbstractPanelLayerDataProvider
24
    {
25
        return match ($type) {
26 1
            SubspaceLayerTypeEnum::ALL => new GeneralSubspaceDataProvider($this->locationRepository, $this->mapRepository, $this->starSystemMapRepository),
27 1
            SubspaceLayerTypeEnum::IGNORE_USER => new IgnoringSubspaceDataProvider($id, $this->stuTime, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository),
28 1
            SubspaceLayerTypeEnum::ALLIANCE_ONLY => new AllianceSubspaceDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository),
29 1
            SubspaceLayerTypeEnum::USER_ONLY => new UserSubspaceDataProvider($id, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository),
30 1
            SubspaceLayerTypeEnum::SPACECRAFT_ONLY => new ShipSubspaceDataProvider($id, $this->stuTime, $this->locationRepository, $this->mapRepository, $this->starSystemMapRepository, $rumpId)
31
        };
32
    }
33
}
34