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

SystemCellData   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 19
c 1
b 1
f 0
dl 0
loc 46
ccs 14
cts 18
cp 0.7778
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getColonyShieldState() 0 3 1
A getSystemFieldId() 0 7 2
A __construct() 0 14 1
A getSystemBackgroundId() 0 6 1
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