Passed
Pull Request — master (#2257)
by Janko
10:11 queued 05:17
created

Layer   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Test Coverage

Coverage 53.66%

Importance

Changes 0
Metric Value
eloc 55
dl 0
loc 140
ccs 22
cts 41
cp 0.5366
rs 10
c 0
b 0
f 0
wmc 20

16 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A getSectorsVertical() 0 3 1
A isHidden() 0 3 1
A getHeight() 0 3 1
A getWidth() 0 3 1
A getName() 0 3 1
A getId() 0 3 1
A setDescription() 0 5 1
A isFinished() 0 7 2
A getSectorsHorizontal() 0 3 1
A getSectorId() 0 3 1
A getAward() 0 3 1
A getSectorCount() 0 3 1
A isEncoded() 0 7 2
A isColonizable() 0 7 2
A isNoobzone() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Doctrine\ORM\Mapping\GeneratedValue;
10
use Doctrine\ORM\Mapping\Id;
11
use Doctrine\ORM\Mapping\JoinColumn;
12
use Doctrine\ORM\Mapping\ManyToOne;
13
use Doctrine\ORM\Mapping\Table;
14
use Stu\Component\Map\MapEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Map\MapEnum 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...
15
use Stu\Orm\Repository\LayerRepository;
16
17
#[Table(name: 'stu_layer')]
18
#[Entity(repositoryClass: LayerRepository::class)]
19
class Layer
20
{
21
    #[Id]
22
    #[Column(type: 'integer')]
23
    #[GeneratedValue(strategy: 'IDENTITY')]
24
    private int $id;
25
26
    #[Column(type: 'string')]
27
    private string $name;
28
29
    #[Column(type: 'integer')]
30
    private int $width;
31
32
    #[Column(type: 'integer')]
33
    private int $height;
34
35
    #[Column(type: 'boolean')]
36
    private bool $is_hidden;
37
38
    #[Column(type: 'boolean', nullable: true)]
39
    private ?bool $is_finished = null;
40
41
    #[Column(type: 'boolean', nullable: true)]
42
    private ?bool $is_encoded = null;
43
44
    #[Column(type: 'integer', nullable: true)]
45
    private ?int $award_id = null;
0 ignored issues
show
introduced by
The private property $award_id is not used, and could be removed.
Loading history...
46
47
    #[Column(type: 'text', nullable: true)]
48
    private ?string $description = null;
49
50
    #[Column(type: 'boolean', nullable: true)]
51
    private ?bool $is_colonizable = null;
52
53
    #[Column(type: 'boolean', nullable: true)]
54
    private ?bool $is_noobzone = null;
55
56
    #[ManyToOne(targetEntity: Award::class)]
57
    #[JoinColumn(name: 'award_id', referencedColumnName: 'id')]
58
    private ?Award $award = null;
59
60
61 26
    public function getId(): int
62
    {
63 26
        return $this->id;
64
    }
65
66 9
    public function getName(): string
67
    {
68 9
        return $this->name;
69
    }
70
71 13
    public function getWidth(): int
72
    {
73 13
        return $this->width;
74
    }
75
76 13
    public function getHeight(): int
77
    {
78 13
        return $this->height;
79
    }
80
81
    public function isHidden(): bool
82
    {
83
        return $this->is_hidden;
84
    }
85
86
    public function isFinished(): bool
87
    {
88
        if ($this->is_finished === null) {
89
            return false;
90
        }
91
92
        return $this->is_finished;
93
    }
94
95 5
    public function isEncoded(): bool
96
    {
97 5
        if ($this->is_encoded === null) {
98
            return false;
99
        }
100
101 5
        return $this->is_encoded;
102
    }
103
104
    public function getAward(): ?Award
105
    {
106
        return $this->award;
107
    }
108
109
    public function getDescription(): ?string
110
    {
111
        return $this->description;
112
    }
113
114
    public function setDescription(?string $description): Layer
115
    {
116
        $this->description = $description;
117
118
        return $this;
119
    }
120
121
    public function isColonizable(): bool
122
    {
123
        if ($this->is_colonizable === null) {
124
            return false;
125
        }
126
127
        return $this->is_colonizable;
128
    }
129
130 1
    public function isNoobzone(): bool
131
    {
132 1
        if ($this->is_noobzone === null) {
133 1
            return false;
134
        }
135
136
        return $this->is_noobzone;
137
    }
138
139 4
    public function getSectorsHorizontal(): int
140
    {
141 4
        return (int)ceil($this->getWidth() / MapEnum::FIELDS_PER_SECTION);
142
    }
143
144 4
    public function getSectorsVertical(): int
145
    {
146 4
        return (int)ceil($this->getHeight() / MapEnum::FIELDS_PER_SECTION);
147
    }
148
149 4
    public function getSectorCount(): int
150
    {
151 4
        return $this->getSectorsVertical() * $this->getSectorsHorizontal();
152
    }
153
154 1
    public function getSectorId(int $mapCx, int $mapCy): int
155
    {
156 1
        return $mapCx + ($mapCy - 1) * $this->getSectorsHorizontal();
157
    }
158
}
159