Passed
Push — master ( 3d0840...13d157 )
by Nico
48:12 queued 22:32
created

AbstractReactorSystemData::__construct()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Ship\System\Data;
6
7
use Stu\Component\Ship\System\ShipSystemTypeEnum;
8
use Stu\Orm\Repository\ShipSystemRepositoryInterface;
9
10
abstract class AbstractReactorSystemData extends AbstractSystemData
11
{
12
    public int $output = 0;
13
    public int $load = 0;
14
15
    private ShipSystemRepositoryInterface $shipSystemRepository;
16
17
    public function __construct(ShipSystemRepositoryInterface $shipSystemRepository)
18
    {
19
        $this->shipSystemRepository = $shipSystemRepository;
20
    }
21
22
    public function update(): void
23
    {
24
        $this->updateSystemData(
25
            $this->getSystemType(),
26
            $this,
27
            $this->shipSystemRepository
28
        );
29
    }
30
31
    abstract function getSystemType(): ShipSystemTypeEnum;
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
32
33
    public abstract function getIcon(): string;
34
35
    public abstract function getLoadUnits(): int;
36
37
    /** @return array<int, int> */
38
    public abstract function getLoadCost(): array;
39
40
    public abstract function getCapacity(): int;
41
42
    /**
43
     * proportional to reactor system status
44
     */
45
    public function getOutput(): int
46
    {
47
        return (int) (ceil($this->output
48
            * $this->ship->getShipSystem($this->getSystemType())->getStatus() / 100));
49
    }
50
51
    public function getTheoreticalReactorOutput(): int
52
    {
53
        return $this->output;
54
    }
55
56
    public function setOutput(int $output): AbstractReactorSystemData
57
    {
58
        $this->output = $output;
59
        return $this;
60
    }
61
62
    public function getLoad(): int
63
    {
64
        return $this->load;
65
    }
66
67
    public function setLoad(int $load): AbstractReactorSystemData
68
    {
69
        $this->load = $load;
70
71
        return $this;
72
    }
73
}
74