Passed
Pull Request — master (#1685)
by Nico
30:06
created

WarpCoreSystemData::setWarpCoreSplit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
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
    /** @deprecated */
35
    public function getWarpCoreSplit(): int
36
    {
37
        return $this->split;
38
    }
39
}
40