Passed
Pull Request — master (#1830)
by Nico
30:56
created

AbstractReactorSystemData::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A AbstractReactorSystemData::getOutput() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Ship\System\Data;
6
7
abstract class AbstractReactorSystemData extends AbstractSystemData
8
{
9
    public int $output = 0;
10
    public int $load = 0;
11
12
    public abstract function getIcon(): string;
13
14
    public abstract function getLoadUnits(): int;
15
16
    /** @return array<int, int> */
17
    public abstract function getLoadCost(): array;
18
19
    public abstract function getCapacity(): int;
20
21
    /**
22
     * proportional to reactor system status
23
     */
24
    public function getOutput(): int
25
    {
26
        return (int) (ceil($this->output
27
            * $this->ship->getShipSystem($this->getSystemType())->getStatus() / 100));
28
    }
29
30
    public function getTheoreticalReactorOutput(): int
31
    {
32
        return $this->output;
33
    }
34
35
    public function setOutput(int $output): AbstractReactorSystemData
36
    {
37
        $this->output = $output;
38
        return $this;
39
    }
40
41
    public function getLoad(): int
42
    {
43
        return $this->load;
44
    }
45
46
    public function setLoad(int $load): AbstractReactorSystemData
47
    {
48
        $this->load = $load;
49
50
        return $this;
51
    }
52
}
53