Passed
Push — dev ( 39c2d9...27d5b2 )
by Janko
07:39
created

Layer::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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\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\Table;
12
use Stu\Component\Map\MapEnum;
13
14
/**
15
 * @Entity(repositoryClass="Stu\Orm\Repository\LayerRepository")
16
 * @Table(
17
 *     name="stu_layer"
18
 * )
19
 **/
20
class Layer implements LayerInterface
21
{
22
    /**
23
     * @Id
24
     * @Column(type="integer")
25
     * @GeneratedValue(strategy="IDENTITY")
26
     *
27
     */
28
    private int $id;
29
30
    /**
31
     * @Column(type="string")
32
     *
33
     */
34
    private string $name;
35
36
    /**
37
     * @Column(type="integer")
38
     *
39
     */
40
    private int $width;
41
42
    /**
43
     * @Column(type="integer")
44
     *
45
     */
46
    private int $height;
47
48
    /**
49
     * @Column(type="boolean")
50
     *
51
     */
52
    private bool $is_hidden;
53
54
    /**
55
     * @Column(type="boolean", nullable=true)
56
     *
57
     */
58
    private ?bool $is_finished = null;
59
60
    public function getId(): int
61
    {
62
        return $this->id;
63
    }
64
65
    public function getName(): string
66
    {
67
        return $this->name;
68
    }
69
70
    public function getWidth(): int
71
    {
72
        return $this->width;
73
    }
74
75
    public function getHeight(): int
76
    {
77
        return $this->height;
78
    }
79
80
    public function isHidden(): bool
81
    {
82
        return $this->is_hidden;
83
    }
84
85
    public function isFinished(): bool
86
    {
87
        if ($this->is_finished === null) {
88
            return false;
89
        }
90
91
        return $this->is_finished;
92
    }
93
94
    public function getSectorId(int $mapCx, int $mapCy): int
95
    {
96
        return $mapCx + ($mapCy - 1) * (int)ceil($this->getWidth() / MapEnum::FIELDS_PER_SECTION);
97
    }
98
}
99