Passed
Push — dev ( ac26ef...6b8aca )
by Nico
08:29
created

WarpCoreSystemData   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 33
ccs 0
cts 14
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setWarpCoreSplit() 0 4 1
A update() 0 9 1
A getWarpCoreSplit() 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
class WarpCoreSystemData extends AbstractSystemData
11
{
12
    // warpdrive fields
13
    public int $split = 100;
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
        // Überprüfe und begrenze den Wert zwischen 0 und 100
25
        $this->split = max(0, min(100, $this->split));
26
27
        $this->updateSystemData(
28
            ShipSystemTypeEnum::SYSTEM_WARPCORE,
29
            $this,
30
            $this->shipSystemRepository
31
        );
32
    }
33
34
    public function getWarpCoreSplit(): int
35
    {
36
        return $this->split;
37
    }
38
39
    public function setWarpCoreSplit(int $split): WarpCoreSystemData
40
    {
41
        $this->split = $split;
42
        return $this;
43
    }
44
}