1 | <?php |
||
2 | |||
3 | namespace LSB\NumberingBundle\Entity; |
||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; |
||
6 | use LSB\NumberingBundle\Model\TimeContext; |
||
7 | use Symfony\Component\Validator\Constraints as Assert; |
||
8 | |||
9 | |||
10 | /** |
||
11 | * Class NumberingCounterData |
||
12 | * @package LSB\NumberingBundle\Entity |
||
13 | * |
||
14 | * @ORM\Entity(repositoryClass="LSB\NumberingBundle\Repository\NumberingCounterDataRepository") |
||
15 | * @ORM\Table(name="numbering_counter_data") |
||
16 | */ |
||
17 | class NumberingCounterData |
||
18 | { |
||
19 | const DEFAULT_START = 1; |
||
20 | const DEFAULT_STEP = 1; |
||
21 | |||
22 | /** |
||
23 | * @var integer|null |
||
24 | * @ORM\Id() |
||
25 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
26 | * @ORM\Column(type="integer") |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * Pattern name from configuration |
||
32 | * |
||
33 | * @var string|null |
||
34 | * @ORM\Column(type="string", length=255, nullable=true) |
||
35 | * @Assert\Length(max=255) |
||
36 | */ |
||
37 | protected $configName; |
||
38 | |||
39 | /** |
||
40 | * Initial value of the counter |
||
41 | * |
||
42 | * @var integer |
||
43 | * |
||
44 | * @ORM\Column(type="integer", nullable=false) |
||
45 | */ |
||
46 | protected $start = self::DEFAULT_START; |
||
47 | |||
48 | /** |
||
49 | * Step of the counter |
||
50 | * |
||
51 | * @var integer |
||
52 | * |
||
53 | * @ORM\Column(type="integer", nullable=false) |
||
54 | */ |
||
55 | protected $step = self::DEFAULT_STEP; |
||
56 | |||
57 | |||
58 | /** |
||
59 | * Current value of the counter |
||
60 | * |
||
61 | * @var integer |
||
62 | * @ORM\Column(type="integer", nullable=false) |
||
63 | */ |
||
64 | protected $current = self::DEFAULT_START; |
||
65 | |||
66 | |||
67 | /** |
||
68 | * FQCN of the subject object |
||
69 | * |
||
70 | * @var string|null |
||
71 | * @ORM\Column(type="string", length=255, nullable=true) |
||
72 | * @Assert\Length(max=255) |
||
73 | */ |
||
74 | protected $subjectFQCN; |
||
75 | |||
76 | /** |
||
77 | * Time context type e.g. "year" or "month", if specified, current value will be determined in that context |
||
78 | * @see TimeContext |
||
79 | * |
||
80 | * @var string|null |
||
81 | * @ORM\Column(type="string", length=30, nullable=true) |
||
82 | * @Assert\Length(max=30) |
||
83 | */ |
||
84 | protected $timeContext; |
||
85 | |||
86 | /** |
||
87 | * Time context value e.g. 2019, if time context specified |
||
88 | * |
||
89 | * @var integer|null |
||
90 | * @ORM\Column(type="integer", nullable=true) |
||
91 | */ |
||
92 | protected $timeContextValue; |
||
93 | |||
94 | /** |
||
95 | * FQCN of the context object |
||
96 | * |
||
97 | * @var string|null |
||
98 | * @ORM\Column(type="string", length=255, nullable=true) |
||
99 | * @Assert\Length(max=255) |
||
100 | */ |
||
101 | protected $contextObjectFQCN; |
||
102 | |||
103 | /** |
||
104 | * Object context value |
||
105 | * |
||
106 | * @var string|null |
||
107 | * @ORM\Column(type="string", length=255, nullable=true) |
||
108 | * @Assert\Length(max=255) |
||
109 | */ |
||
110 | protected $contextObjectValue; |
||
111 | |||
112 | |||
113 | /** |
||
114 | * NumberingCounterData constructor. |
||
115 | */ |
||
116 | 3 | public function __construct() |
|
117 | { |
||
118 | 3 | } |
|
119 | |||
120 | |||
121 | 1 | public function __clone() |
|
122 | { |
||
123 | 1 | if ($this->getId()) { |
|
0 ignored issues
–
show
|
|||
124 | $this->setId(null); |
||
125 | } |
||
126 | 1 | } |
|
127 | |||
128 | /** |
||
129 | * @return int|null |
||
130 | */ |
||
131 | 2 | public function getId(): ?int |
|
132 | { |
||
133 | 2 | return $this->id; |
|
134 | } |
||
135 | |||
136 | /** |
||
137 | * @param int|null $id |
||
138 | * @return $this |
||
139 | */ |
||
140 | 1 | public function setId(?int $id): NumberingCounterData |
|
141 | { |
||
142 | 1 | $this->id = $id; |
|
143 | 1 | return $this; |
|
144 | } |
||
145 | |||
146 | /** |
||
147 | * @return string|null |
||
148 | */ |
||
149 | 1 | public function getConfigName(): ?string |
|
150 | { |
||
151 | 1 | return $this->configName; |
|
152 | } |
||
153 | |||
154 | /** |
||
155 | * @param string|null $configName |
||
156 | * @return NumberingCounterData |
||
157 | */ |
||
158 | 1 | public function setConfigName(?string $configName): NumberingCounterData |
|
159 | { |
||
160 | 1 | $this->configName = $configName; |
|
161 | 1 | return $this; |
|
162 | } |
||
163 | |||
164 | /** |
||
165 | * @return int |
||
166 | */ |
||
167 | 1 | public function getStart(): int |
|
168 | { |
||
169 | 1 | return $this->start; |
|
170 | } |
||
171 | |||
172 | /** |
||
173 | * @param int $start |
||
174 | * @return NumberingCounterData |
||
175 | */ |
||
176 | 1 | public function setStart(int $start): NumberingCounterData |
|
177 | { |
||
178 | 1 | $this->start = $start; |
|
179 | 1 | return $this; |
|
180 | } |
||
181 | |||
182 | /** |
||
183 | * @return int |
||
184 | */ |
||
185 | 1 | public function getStep(): int |
|
186 | { |
||
187 | 1 | return $this->step; |
|
188 | } |
||
189 | |||
190 | /** |
||
191 | * @param int $step |
||
192 | * @return NumberingCounterData |
||
193 | */ |
||
194 | 1 | public function setStep(int $step): NumberingCounterData |
|
195 | { |
||
196 | 1 | $this->step = $step; |
|
197 | 1 | return $this; |
|
198 | } |
||
199 | |||
200 | /** |
||
201 | * @return int |
||
202 | */ |
||
203 | 1 | public function getCurrent(): int |
|
204 | { |
||
205 | 1 | return $this->current; |
|
206 | } |
||
207 | |||
208 | /** |
||
209 | * @param int $current |
||
210 | * @return NumberingCounterData |
||
211 | */ |
||
212 | 1 | public function setCurrent(int $current): NumberingCounterData |
|
213 | { |
||
214 | 1 | $this->current = $current; |
|
215 | 1 | return $this; |
|
216 | } |
||
217 | |||
218 | /** |
||
219 | * @return string|null |
||
220 | */ |
||
221 | 1 | public function getSubjectFQCN(): ?string |
|
222 | { |
||
223 | 1 | return $this->subjectFQCN; |
|
224 | } |
||
225 | |||
226 | /** |
||
227 | * @param string|null $subjectFQCN |
||
228 | * @return NumberingCounterData |
||
229 | */ |
||
230 | 1 | public function setSubjectFQCN(?string $subjectFQCN): NumberingCounterData |
|
231 | { |
||
232 | 1 | $this->subjectFQCN = $subjectFQCN; |
|
233 | 1 | return $this; |
|
234 | } |
||
235 | |||
236 | /** |
||
237 | * @return string|null |
||
238 | */ |
||
239 | 1 | public function getTimeContext(): ?string |
|
240 | { |
||
241 | 1 | return $this->timeContext; |
|
242 | } |
||
243 | |||
244 | /** |
||
245 | * @param string|null $timeContext |
||
246 | * @return NumberingCounterData |
||
247 | */ |
||
248 | 1 | public function setTimeContext(?string $timeContext): NumberingCounterData |
|
249 | { |
||
250 | 1 | $this->timeContext = $timeContext; |
|
251 | 1 | return $this; |
|
252 | } |
||
253 | |||
254 | /** |
||
255 | * @return int|null |
||
256 | */ |
||
257 | 1 | public function getTimeContextValue(): ?int |
|
258 | { |
||
259 | 1 | return $this->timeContextValue; |
|
260 | } |
||
261 | |||
262 | /** |
||
263 | * @param int|null $timeContextValue |
||
264 | * @return NumberingCounterData |
||
265 | */ |
||
266 | 1 | public function setTimeContextValue(?int $timeContextValue): NumberingCounterData |
|
267 | { |
||
268 | 1 | $this->timeContextValue = $timeContextValue; |
|
269 | 1 | return $this; |
|
270 | } |
||
271 | |||
272 | /** |
||
273 | * @return string|null |
||
274 | */ |
||
275 | 1 | public function getContextObjectFQCN(): ?string |
|
276 | { |
||
277 | 1 | return $this->contextObjectFQCN; |
|
278 | } |
||
279 | |||
280 | /** |
||
281 | * @param string|null $contextObjectFQCN |
||
282 | * @return NumberingCounterData |
||
283 | */ |
||
284 | 1 | public function setContextObjectFQCN(?string $contextObjectFQCN): NumberingCounterData |
|
285 | { |
||
286 | 1 | $this->contextObjectFQCN = $contextObjectFQCN; |
|
287 | 1 | return $this; |
|
288 | } |
||
289 | |||
290 | /** |
||
291 | * @return string|null |
||
292 | */ |
||
293 | 1 | public function getContextObjectValue(): ?string |
|
294 | { |
||
295 | 1 | return $this->contextObjectValue; |
|
296 | } |
||
297 | |||
298 | /** |
||
299 | * @param string|null $contextObjectValue |
||
300 | * @return NumberingCounterData |
||
301 | */ |
||
302 | 1 | public function setContextObjectValue(?string $contextObjectValue): NumberingCounterData |
|
303 | { |
||
304 | 1 | $this->contextObjectValue = $contextObjectValue; |
|
305 | 1 | return $this; |
|
306 | } |
||
307 | |||
308 | |||
309 | } |
||
310 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: