Test Failed
Push — master ( bbdbb0...ecc533 )
by Nico
16:37 queued 10:47
created

ManagerProviderSpacecraft::getFreeCrewAmount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\SpacecraftManagement\Provider;
6
7
use BadMethodCallException;
8
use Doctrine\Common\Collections\Collection;
9
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface;
10
use Stu\Orm\Entity\Commodity;
11
use Stu\Orm\Entity\Spacecraft;
12
use Stu\Orm\Entity\User;
13
14
class ManagerProviderSpacecraft implements ManagerProviderInterface
15
{
16
    public function __construct(
17
        private SpacecraftWrapperInterface $wrapper
18
    ) {}
19
20
    #[\Override]
21
    public function getUser(): User
22
    {
23
        return $this->wrapper->get()->getUser();
24
    }
25
26
    #[\Override]
27
    public function getEps(): int
28
    {
29
        return 0;
30
    }
31
32
    #[\Override]
33
    public function lowerEps(int $amount): ManagerProviderInterface
34
    {
35
        throw new BadMethodCallException('spacecraft can not lower eps for transfer');
36
    }
37
38
    #[\Override]
39
    public function getName(): string
40
    {
41
        $spacecraft = $this->wrapper->get();
42
43
        return sprintf(
44
            '%s %s',
45
            $spacecraft->getRump()->getName(),
46
            $spacecraft->getName(),
47
        );
48
    }
49
50
    #[\Override]
51
    public function getSectorString(): string
52
    {
53
        return $this->wrapper->get()->getSectorString();
54
    }
55
56
    #[\Override]
57
    public function getFreeCrewAmount(): int
58
    {
59
        return 0;
60
    }
61
62
    #[\Override]
63
    public function addCrewAssignment(Spacecraft $spacecraft, int $amount): void
64
    {
65
        throw new BadMethodCallException('spacecraft can not add crew for transfer');
66
    }
67
68
    #[\Override]
69
    public function getFreeCrewStorage(): int
70
    {
71
        return 0;
72
    }
73
74
    #[\Override]
75
    public function addCrewAssignments(array $crewAssignments): void
76
    {
77
        throw new BadMethodCallException('spacecraft can not add crew for transfer');
78
    }
79
80
    #[\Override]
81
    public function getStorage(): Collection
82
    {
83
        return $this->wrapper->get()->getStorage();
84
    }
85
86
    #[\Override]
87
    public function upperStorage(Commodity $commodity, int $amount): void
88
    {
89
        throw new BadMethodCallException('spacecraft can not upper storage for transfer');
90
    }
91
92
    #[\Override]
93
    public function lowerStorage(Commodity $commodity, int $amount): void
94
    {
95
        throw new BadMethodCallException('spacecraft can not lower storage for transfer');
96
    }
97
98
    public function getReactorLoad(): int
99
    {
100
        $reactor = $this->wrapper->getReactorWrapper();
101
        return $reactor ? $reactor->getLoad() : 0;
102
    }
103
104
    public function lowerReactorLoad(int $amount): void
105
    {
106
        $reactor = $this->wrapper->getReactorWrapper();
107
        if ($reactor === null) {
108
            throw new BadMethodCallException('spacecraft has no reactor');
109
        }
110
111
        $reactor->changeLoad(-$amount);
112
    }
113
}
114