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

ConstructionProgressWrapper::getRemainingTicks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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