Passed
Push — master ( 66afc8...ff3c83 )
by Janko
09:01
created

AstronomicalEntry::setAstroStartTurn()   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 1
dl 0
loc 4
ccs 0
cts 3
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\Index;
12
use Doctrine\ORM\Mapping\JoinColumn;
13
use Doctrine\ORM\Mapping\ManyToOne;
14
use Doctrine\ORM\Mapping\Table;
15
use Stu\Component\Ship\AstronomicalMappingStateEnum;
16
use Stu\Orm\Attribute\TruncateOnGameReset;
17
use Stu\Orm\Repository\AstroEntryRepository;
18
19
#[Table(name: 'stu_astro_entry')]
20
#[Index(name: 'astro_entry_user_idx', columns: ['user_id'])]
21
#[Index(name: 'astro_entry_star_system_idx', columns: ['systems_id'])]
22
#[Index(name: 'astro_entry_map_region_idx', columns: ['region_id'])]
23
#[Entity(repositoryClass: AstroEntryRepository::class)]
24
#[TruncateOnGameReset]
25
class AstronomicalEntry
26
{
27
    public const int MEASUREMENT_COUNT = 5;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 27 at column 21
Loading history...
28
29
    #[Id]
30
    #[Column(type: 'integer')]
31
    #[GeneratedValue(strategy: 'IDENTITY')]
32
    private int $id;
33
34
    #[Column(type: 'integer')]
35
    private int $user_id = 0;
36
37
    #[Column(type: 'smallint', length: 1, enumType: AstronomicalMappingStateEnum::class)]
38
    private AstronomicalMappingStateEnum $state = AstronomicalMappingStateEnum::PLANNABLE;
39
40
    #[Column(type: 'integer', nullable: true)]
41
    private ?int $astro_start_turn = null;
42
43
    #[Column(type: 'integer', nullable: true)]
44
    private ?int $systems_id = null;
45
46
    #[Column(type: 'integer', nullable: true)]
47
    private ?int $region_id = null;
48
49
    #[Column(type: 'text')]
50
    private string $field_ids = '';
51
52
    #[ManyToOne(targetEntity: User::class)]
53
    #[JoinColumn(name: 'user_id', nullable: false, referencedColumnName: 'id', onDelete: 'CASCADE')]
54
    private User $user;
55
56
    #[ManyToOne(targetEntity: StarSystem::class, inversedBy: 'astronomicalEntries')]
57
    #[JoinColumn(name: 'systems_id', referencedColumnName: 'id')]
58
    private ?StarSystem $starSystem = null;
59
60
61
    #[ManyToOne(targetEntity: MapRegion::class, inversedBy: 'astronomicalEntries')]
62
    #[JoinColumn(name: 'region_id', referencedColumnName: 'id')]
63
    private ?MapRegion $region = null;
64
65
    public function getId(): int
66
    {
67
        return $this->id;
68
    }
69
70
    public function getUserId(): int
71
    {
72
        return $this->user_id;
73
    }
74
75
    public function getUser(): User
76
    {
77
        return $this->user;
78
    }
79
80
    public function setUser(User $user): AstronomicalEntry
81
    {
82
        $this->user = $user;
83
        return $this;
84
    }
85
86
    public function getState(): AstronomicalMappingStateEnum
87
    {
88
        return $this->state;
89
    }
90
91
    public function setState(AstronomicalMappingStateEnum $state): AstronomicalEntry
92
    {
93
        $this->state = $state;
94
        return $this;
95
    }
96
97
    public function getAstroStartTurn(): ?int
98
    {
99
        return $this->astro_start_turn;
100
    }
101
102
    public function setAstroStartTurn(?int $turn): AstronomicalEntry
103
    {
104
        $this->astro_start_turn = $turn;
105
        return $this;
106
    }
107
108
    public function getSystem(): ?StarSystem
109
    {
110
        return $this->starSystem;
111
    }
112
113
    public function setSystem(StarSystem $starSystem): AstronomicalEntry
114
    {
115
        $this->starSystem = $starSystem;
116
        return $this;
117
    }
118
119
    public function getRegion(): ?MapRegion
120
    {
121
        return $this->region;
122
    }
123
124
    public function setRegion(MapRegion $region): AstronomicalEntry
125
    {
126
        $this->region = $region;
127
        return $this;
128
    }
129
130
    public function getFieldIds(): string
131
    {
132
        return $this->field_ids;
133
    }
134
135
    public function setFieldIds(string $fieldIds): AstronomicalEntry
136
    {
137
        $this->field_ids = $fieldIds;
138
        return $this;
139
    }
140
141
    public function isMeasured(): bool
142
    {
143
        return $this->getFieldIds() === '' || $this->getFieldIds() === '0';
144
    }
145
}
146