Passed
Push — dev ( b01017...737777 )
by Janko
05:10
created

FleetWrapper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 31
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A get() 0 4 1
A getShipWrappers() 0 4 1
A isForeignFleet() 0 4 2
A getLeadWrapper() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\Lib;
6
7
use Doctrine\Common\Collections\Collection;
8
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...
9
use Stu\Module\Control\GameControllerInterface;
10
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperFactoryInterface;
11
use Stu\Orm\Entity\Fleet;
12
13
final class FleetWrapper implements FleetWrapperInterface
14
{
15 15
    public function __construct(
16
        private Fleet $fleet,
17
        private SpacecraftWrapperFactoryInterface $spacecraftWrapperFactory,
18
        private GameControllerInterface $game,
19
        private bool $isSingleShips
20 15
    ) {}
21
22 6
    #[Override]
23
    public function get(): Fleet
24
    {
25 6
        return $this->fleet;
26
    }
27
28 6
    #[Override]
29
    public function getLeadWrapper(): ShipWrapperInterface
30
    {
31 6
        return $this->spacecraftWrapperFactory->wrapShip($this->fleet->getLeadShip());
32
    }
33
34 14
    #[Override]
35
    public function getShipWrappers(): Collection
36
    {
37 14
        return $this->spacecraftWrapperFactory->wrapShips($this->fleet->getShips()->toArray());
38
    }
39
40
    #[Override]
41
    public function isForeignFleet(): bool
42
    {
43
        return !$this->isSingleShips && $this->fleet->getUser()->getId() !== $this->game->getUser()->getId();
44
    }
45
}
46