Passed
Push — master ( 95eee2...124208 )
by Nico
15:21 queued 07:35
created

SystemCellData::getSystemFieldId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 3
c 1
b 1
f 0
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\Map\VisualPanel;
6
7
class SystemCellData extends CellData
8
{
9
    public const ONLY_BACKGROUND_IMAGE = 1;
10
11
    private int $x;
12
    private int $y;
13
    private int $systemFieldId;
14
    private bool $colonyShieldState;
15
16 4
    public function __construct(
17
        int $x,
18
        int $y,
19
        int $systemFieldId,
20
        bool $colonyShieldState,
21
        ?string $subspaceCode,
22
        ?string $displayCount
23
    ) {
24 4
        parent::__construct($subspaceCode, $displayCount);
25
26 4
        $this->x = $x;
27 4
        $this->y = $y;
28 4
        $this->systemFieldId = $systemFieldId;
29 4
        $this->colonyShieldState = $colonyShieldState;
30
    }
31
32 4
    public function getSystemBackgroundId(): string
33
    {
34 4
        return sprintf(
35 4
            '%02d%02d',
36 4
            $this->y,
37 4
            $this->x
38 4
        );
39
    }
40
41
    public function getSystemFieldId(): ?int
42
    {
43
        if ($this->systemFieldId === self::ONLY_BACKGROUND_IMAGE) {
44
            return null;
45
        }
46
47
        return $this->systemFieldId;
48
    }
49
50 4
    public function getColonyShieldState(): bool
51
    {
52 4
        return $this->colonyShieldState;
53
    }
54
}
55