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

WarpCoreSystemData::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
ccs 0
cts 6
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
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
}