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

AbstractReactorSystemData   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 62
ccs 0
cts 21
cp 0
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setOutput() 0 4 1
A update() 0 6 1
A setLoad() 0 5 1
A getOutput() 0 4 1
A __construct() 0 3 1
A getTheoreticalReactorOutput() 0 3 1
A getLoad() 0 3 1
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