Test Failed
Push — dev ( d4c172...a63c79 )
by Janko
09:28
created

ManagerProviderColony::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\SpacecraftManagement\Provider;
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\Lib\Transfer\Storage\StorageManagerInterface;
10
use Stu\Module\Colony\Lib\ColonyLibFactoryInterface;
11
use Stu\Module\Crew\Lib\CrewCreatorInterface;
12
use Stu\Module\Spacecraft\Lib\Crew\TroopTransferUtilityInterface;
13
use Stu\Orm\Entity\ColonyInterface;
14
use Stu\Orm\Entity\CommodityInterface;
15
use Stu\Orm\Entity\SpacecraftInterface;
16
use Stu\Orm\Entity\UserInterface;
17
18
class ManagerProviderColony implements ManagerProviderInterface
19
{
20
    public function __construct(private ColonyInterface $colony, private CrewCreatorInterface $crewCreator, private ColonyLibFactoryInterface $colonyLibFactory, private StorageManagerInterface $storageManager, private TroopTransferUtilityInterface $troopTransferUtility) {}
21
22
    #[Override]
23
    public function getUser(): UserInterface
24
    {
25
        return $this->colony->getUser();
26
    }
27
28
    #[Override]
29
    public function getEps(): int
30
    {
31
        return $this->colony->getEps();
32
    }
33
34
    #[Override]
35
    public function lowerEps(int $amount): ManagerProviderInterface
36
    {
37
        $this->colony->lowerEps($amount);
38
39
        return $this;
40
    }
41
42
    #[Override]
43
    public function getName(): string
44
    {
45
        return sprintf('Kolonie %s', $this->colony->getName());
46
    }
47
48
    #[Override]
49
    public function getSectorString(): string
50
    {
51
        return $this->colony->getSectorString();
52
    }
53
54
    #[Override]
55
    public function getFreeCrewAmount(): int
56
    {
57
        return $this->colony->getCrewAssignmentAmount();
58
    }
59
60
    #[Override]
61
    public function addCrewAssignment(SpacecraftInterface $spacecraft, int $amount): void
62
    {
63
        $this->crewCreator->createCrewAssignment($spacecraft, $this->colony, $amount);
64
    }
65
66
    #[Override]
67
    public function getFreeCrewStorage(): int
68
    {
69
        return $this->colonyLibFactory->createColonyPopulationCalculator(
70
            $this->colony
71
        )->getFreeAssignmentCount();
72
    }
73
74
    #[Override]
75
    public function addCrewAssignments(array $crewAssignments): void
76
    {
77
        foreach ($crewAssignments as $crewAssignment) {
78
            $this->troopTransferUtility->assignCrew($crewAssignment, $this->colony);
79
        }
80
    }
81
82
    #[Override]
83
    public function getStorage(): Collection
84
    {
85
        return $this->colony->getStorage();
86
    }
87
88
    #[Override]
89
    public function upperStorage(CommodityInterface $commodity, int $amount): void
90
    {
91
        $this->storageManager->upperStorage(
92
            $this->colony,
93
            $commodity,
94
            $amount
95
        );
96
    }
97
98
    #[Override]
99
    public function lowerStorage(CommodityInterface $commodity, int $amount): void
100
    {
101
        $this->storageManager->lowerStorage(
102
            $this->colony,
103
            $commodity,
104
            $amount
105
        );
106
    }
107
}
108