Passed
Pull Request — master (#1969)
by Janko
22:34 queued 10:03
created

ConstructionProgressWrapper   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 37
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getDockedWorkbeeCount() 0 3 1
A __construct() 0 6 1
A getWorkbeeColor() 0 3 2
A getNeededWorkbeeCount() 0 3 1
A isScrapped() 0 3 1
A isUnderConstruction() 0 3 1
A getRemainingTicks() 0 3 1
1
<?php
2
3
namespace Stu\Module\Station\View\ShowStation;
4
5
use Stu\Component\Spacecraft\SpacecraftStateEnum;
6
use Stu\Orm\Entity\ConstructionProgressInterface;
7
use Stu\Orm\Entity\StationInterface;
8
9
class ConstructionProgressWrapper
10
{
11
    public function __construct(
12
        private ConstructionProgressInterface $progress,
13
        private StationInterface $station,
14
        private int $dockedWorbeeCount,
15
        private int $neededWorbeeCount
16
    ) {}
17
18
    public function isUnderConstruction(): bool
19
    {
20
        return $this->station->getState() == SpacecraftStateEnum::SHIP_STATE_UNDER_CONSTRUCTION;
21
    }
22
23
    public function isScrapped(): bool
24
    {
25
        return $this->station->getState() == SpacecraftStateEnum::SHIP_STATE_UNDER_SCRAPPING;
26
    }
27
28
    public function getRemainingTicks(): int
29
    {
30
        return $this->progress->getRemainingTicks();
31
    }
32
33
    public function getDockedWorkbeeCount(): int
34
    {
35
        return $this->dockedWorbeeCount;
36
    }
37
38
    public function getNeededWorkbeeCount(): int
39
    {
40
        return $this->neededWorbeeCount;
41
    }
42
43
    public function getWorkbeeColor(): string
44
    {
45
        return $this->dockedWorbeeCount < $this->neededWorbeeCount ? 'red' : 'green';
46
    }
47
}
48