Passed
Pull Request — master (#2027)
by Nico
21:19 queued 10:33
created

StarSystemMap::getFieldStyle()   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 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\ORM\Mapping\Column;
10
use Doctrine\ORM\Mapping\Entity;
11
use Doctrine\ORM\Mapping\JoinColumn;
12
use Doctrine\ORM\Mapping\ManyToOne;
13
use Doctrine\ORM\Mapping\OneToMany;
14
use Doctrine\ORM\Mapping\OneToOne;
15
use Doctrine\ORM\Mapping\Table;
16
use Doctrine\ORM\Mapping\UniqueConstraint;
17
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Stu\Orm\Repository\StarSystemMapRepository;
19
20
#[Table(name: 'stu_sys_map')]
21
#[UniqueConstraint(name: 'system_coordinates_idx', columns: ['sx', 'sy', 'systems_id'])]
22
#[Entity(repositoryClass: StarSystemMapRepository::class)]
23
class StarSystemMap extends Location implements StarSystemMapInterface
24
{
25
    #[Column(type: 'smallint')]
26
    private int $sx = 0;
27
28
    #[Column(type: 'smallint')]
29
    private int $sy = 0;
30
31
    #[Column(type: 'integer')]
32
    private int $systems_id = 0;
33
34
    #[ManyToOne(targetEntity: 'StarSystem', inversedBy: 'fields')]
35
    #[JoinColumn(name: 'systems_id', referencedColumnName: 'id')]
36
    private StarSystemInterface $starSystem;
37
38
    #[OneToOne(targetEntity: 'Colony', mappedBy: 'starsystem_map')]
39
    private ?ColonyInterface $colony = null;
40
41
    /**
42
     * @var ArrayCollection<int, WormholeEntryInterface>
43
     */
44
    #[OneToMany(targetEntity: 'WormholeEntry', mappedBy: 'systemMap')]
45
    private Collection $wormholeEntries;
46
47
    public function __construct()
48
    {
49
        parent::__construct();
50
        $this->wormholeEntries = new ArrayCollection();
51
    }
52
53 1
    #[Override]
54
    public function getLayer(): ?LayerInterface
55
    {
56 1
        return $this->layer;
57
    }
58
59 16
    #[Override]
60
    public function getSx(): int
61
    {
62 16
        return $this->sx;
63
    }
64
65
    #[Override]
66
    public function setSx(int $sx): StarSystemMapInterface
67
    {
68
        $this->sx = $sx;
69
70
        return $this;
71
    }
72
73 6
    #[Override]
74
    public function getX(): int
75
    {
76 6
        return $this->getSx();
77
    }
78
79 16
    #[Override]
80
    public function getSy(): int
81
    {
82 16
        return $this->sy;
83
    }
84
85
    #[Override]
86
    public function setSy(int $sy): StarSystemMapInterface
87
    {
88
        $this->sy = $sy;
89
90
        return $this;
91
    }
92
93 6
    #[Override]
94
    public function getY(): int
95
    {
96 6
        return $this->getSy();
97
    }
98
99
    #[Override]
100
    public function getSystemId(): int
101
    {
102
        return $this->systems_id;
103
    }
104
105 14
    #[Override]
106
    public function getSystem(): StarSystemInterface
107
    {
108 14
        return $this->starSystem;
109
    }
110
111
    #[Override]
112
    public function setSystem(StarSystemInterface $starSystem): StarSystemMapInterface
113
    {
114
        $this->starSystem = $starSystem;
115
116
        return $this;
117
    }
118
119
    #[Override]
120
    public function getColony(): ?ColonyInterface
121
    {
122
        return $this->colony;
123
    }
124
125
    #[Override]
126
    public function getMapRegion(): ?MapRegionInterface
127
    {
128
        return null;
129
    }
130
131
    #[Override]
132
    public function getAdministratedRegion(): ?MapRegionInterface
133
    {
134
        return null;
135
    }
136
137
    #[Override]
138
    public function getInfluenceArea(): ?StarSystemInterface
139
    {
140
        return null;
141
    }
142
143
    #[Override]
144
    protected function getWormholeEntries(): Collection
145
    {
146
        return $this->wormholeEntries;
147
    }
148
149
    #[Override]
150
    public function getFieldStyle(): string
151
    {
152
        return "background-image: url('/assets/map/" . $this->getFieldId() . ".png'); opacity:1;";
153
    }
154
155
    #[Override]
156
    public function getSectorId(): ?int
157
    {
158
        $parentMap = $this->getSystem()->getMap();
159
        if ($parentMap === null) {
160
            return null;
161
        }
162
163
        return $parentMap->getSectorId();
164
    }
165
166 3
    #[Override]
167
    public function getSectorString(): string
168
    {
169 3
        return sprintf(
170 3
            '%d|%d (%s-%s)',
171 3
            $this->getSx(),
172 3
            $this->getSy(),
173 3
            $this->getSystem()->getName(),
174 3
            $this->getSystem()->isWormhole() ? 'Wurmloch' : 'System'
175 3
        );
176
    }
177
}
178