Completed
Push — master ( 99d312...5b5b75 )
by Joachim
07:06
created

Currency::getId()   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 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Loevgaard\DandomainFoundation\Entity;
4
5
use Alcohol\ISO4217;
6
use Assert\Assert;
7
use Doctrine\ORM\Mapping as ORM;
8
use Loevgaard\DandomainFoundation\Entity\Generated\CurrencyInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...rated\CurrencyInterface 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...
9
use Loevgaard\DandomainFoundation\Entity\Generated\CurrencyTrait;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...Generated\CurrencyTrait 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...
10
11
/**
12
 * @ORM\Entity()
13
 * @ORM\Table(name="ldf_currencies")
14
 * @ORM\HasLifecycleCallbacks()
15
 */
16
class Currency extends AbstractEntity implements CurrencyInterface
17
{
18
    use CurrencyTrait;
19
20
    protected $hydrateConversions = [
21
        'id' => 'externalId',
22
    ];
23
24
    /**
25
     * @var int
26
     *
27
     * @ORM\Id
28
     * @ORM\GeneratedValue
29
     * @ORM\Column(type="integer")
30
     **/
31
    protected $id;
32
33
    /**
34
     * In Dandomain, the external id and the code has the same contents
35
     * I guess it has something to do with backwards compatibility
36
     *
37
     * @var string|null
38
     *
39
     * @ORM\Column(type="string", unique=true, length=191)
40
     */
41
    protected $externalId;
42
43
    /**
44
     * @var string|null
45
     *
46
     * @ORM\Column(type="string", unique=true, length=191)
47
     */
48
    protected $code;
49
50
    /**
51
     * @var boolean|null
52
     *
53
     * @ORM\Column(type="boolean")
54
     */
55
    protected $deActivated;
56
57
    /**
58
     * @var string|null
59
     *
60
     * @ORM\Column(type="string", length=1)
61
     */
62
    protected $delimiterDecimal;
63
64
    /**
65
     * @var string|null
66
     *
67
     * @ORM\Column(type="string", length=1)
68
     */
69
    protected $delimiterThousand;
70
71
    /**
72
     * @var int|null
73
     *
74
     * @ORM\Column(type="integer")
75
     */
76
    protected $factor;
77
78
    /**
79
     * @var string|null
80
     *
81
     * @ORM\Column(type="string", length=191, nullable=true)
82
     */
83
    protected $icon;
84
85
    /**
86
     * @var boolean|null
87
     *
88
     * @ORM\Column(type="boolean")
89
     */
90
    protected $default;
91
92
    /**
93
     * This is the currency's ISO code
94
     *
95
     * @var int|null
96
     *
97
     * @ORM\Column(type="int")
98
     */
99
    protected $payCode;
100
101
    /**
102
     * @var int|null
103
     *
104
     * @ORM\Column(type="integer")
105
     */
106
    protected $roundCondition;
107
108
    /**
109
     * @var int|null
110
     *
111
     * @ORM\Column(type="integer")
112
     */
113
    protected $roundDirection;
114
115
    /**
116
     * @var string|null
117
     *
118
     * @ORM\Column(type="string", length=191)
119
     */
120
    protected $roundParam;
121
122
    /**
123
     * @var int|null
124
     *
125
     * @ORM\Column(type="integer")
126
     */
127
    protected $roundPrices;
128
129
    /**
130
     * @var string|null
131
     *
132
     * @ORM\Column(type="string", length=191)
133
     */
134
    protected $symbol;
135
136
    /**
137
     * @var int|null
138
     *
139
     * @ORM\Column(type="integer")
140
     */
141
    protected $symbolAlign;
142
143
    /**
144
     * @var string|null
145
     *
146
     * @ORM\Column(type="string", length=191)
147
     */
148
    protected $text;
149
150
    /**
151
     * We have added these two properties (which are not in the Dandomain API)
152
     */
153
    /**
154
     * This is the currency's ISO code (numeric)
155
     *
156
     * @var int|null
157
     *
158
     * @ORM\Column(type="int")
159
     */
160
    protected $isoCodeNumeric;
161
162
    /**
163
     * This is the currency's ISO code (alpha)
164
     *
165
     * @var string|null
166
     *
167
     * @ORM\Column(type="string", length=3)
168
     */
169
    protected $isoCodeAlpha;
170
171
    /**
172
     * @ORM\PreUpdate()
173
     * @ORM\PrePersist()
174
     */
175
    public function validate()
176
    {
177
        Assert::that($this->externalId)->string()->maxLength(191);
178
        Assert::that($this->code)->string()->maxLength(191);
179
        Assert::that($this->deActivated)->boolean();
180
        Assert::that($this->delimiterDecimal)->choice([',', '.']);
181
        Assert::that($this->delimiterThousand)->choice([',', '.']);
182
        Assert::that($this->factor)->integer();
183
        Assert::thatNullOr($this->icon)->string()->maxLength(191);
184
        Assert::that($this->default)->boolean();
185
        Assert::that($this->payCode)->integer();
186
        Assert::that($this->roundCondition)->integer();
187
        Assert::that($this->roundDirection)->integer();
188
        Assert::that($this->roundParam)->string()->maxLength(191);
189
        Assert::that($this->roundPrices)->integer();
190
        Assert::that($this->symbol)->string()->maxLength(191);
191
        Assert::that($this->symbolAlign)->integer();
192
        Assert::that($this->isoCodeNumeric)->integer();
193
        Assert::that($this->text)->string()->maxLength(191);
194
        Assert::that($this->isoCodeAlpha)->string()->length(3);
195
    }
196
197
    /**
198
     * @return int
199
     */
200
    public function getId(): int
201
    {
202
        return $this->id;
203
    }
204
205
    /**
206
     * @param int $id
207
     * @return Currency
208
     */
209
    public function setId(int $id)
210
    {
211
        $this->id = $id;
212
        return $this;
213
    }
214
215
    /**
216
     * @return null|string
217
     */
218
    public function getExternalId(): ?string
219
    {
220
        return $this->externalId;
221
    }
222
223
    /**
224
     * @param null|string $externalId
225
     * @return Currency
226
     */
227
    public function setExternalId(?string $externalId)
228
    {
229
        $this->externalId = $externalId;
230
        return $this;
231
    }
232
233
    /**
234
     * @return null|string
235
     */
236
    public function getCode(): ?string
237
    {
238
        return $this->code;
239
    }
240
241
    /**
242
     * @param null|string $code
243
     * @return Currency
244
     */
245
    public function setCode(?string $code)
246
    {
247
        $this->code = $code;
248
        return $this;
249
    }
250
251
    /**
252
     * @return bool|null
253
     */
254
    public function getDeActivated(): ?bool
255
    {
256
        return $this->deActivated;
257
    }
258
259
    /**
260
     * @param bool|null $deActivated
261
     * @return Currency
262
     */
263
    public function setDeActivated(?bool $deActivated)
264
    {
265
        $this->deActivated = $deActivated;
266
        return $this;
267
    }
268
269
    /**
270
     * @return null|string
271
     */
272
    public function getDelimiterDecimal(): ?string
273
    {
274
        return $this->delimiterDecimal;
275
    }
276
277
    /**
278
     * @param null|string $delimiterDecimal
279
     * @return Currency
280
     */
281
    public function setDelimiterDecimal(?string $delimiterDecimal)
282
    {
283
        $this->delimiterDecimal = $delimiterDecimal;
284
        return $this;
285
    }
286
287
    /**
288
     * @return null|string
289
     */
290
    public function getDelimiterThousand(): ?string
291
    {
292
        return $this->delimiterThousand;
293
    }
294
295
    /**
296
     * @param null|string $delimiterThousand
297
     * @return Currency
298
     */
299
    public function setDelimiterThousand(?string $delimiterThousand)
300
    {
301
        $this->delimiterThousand = $delimiterThousand;
302
        return $this;
303
    }
304
305
    /**
306
     * @return int|null
307
     */
308
    public function getFactor(): ?int
309
    {
310
        return $this->factor;
311
    }
312
313
    /**
314
     * @param int|null $factor
315
     * @return Currency
316
     */
317
    public function setFactor(?int $factor)
318
    {
319
        $this->factor = $factor;
320
        return $this;
321
    }
322
323
    /**
324
     * @return null|string
325
     */
326
    public function getIcon(): ?string
327
    {
328
        return $this->icon;
329
    }
330
331
    /**
332
     * @param null|string $icon
333
     * @return Currency
334
     */
335
    public function setIcon(?string $icon)
336
    {
337
        $this->icon = $icon;
338
        return $this;
339
    }
340
341
    /**
342
     * @return bool|null
343
     */
344
    public function getDefault(): ?bool
345
    {
346
        return $this->default;
347
    }
348
349
    /**
350
     * @param bool|null $default
351
     * @return Currency
352
     */
353
    public function setDefault(?bool $default)
354
    {
355
        $this->default = $default;
356
        return $this;
357
    }
358
359
    /**
360
     * @return int|null
361
     */
362
    public function getPayCode(): ?int
363
    {
364
        return $this->payCode;
365
    }
366
367
    /**
368
     * @param int|null $payCode
369
     * @return Currency
370
     */
371
    public function setPayCode(?int $payCode)
372
    {
373
        $this->payCode = $payCode;
374
        $this->setIsoCodeNumeric($payCode);
375
376
        $iso4217 = new ISO4217();
377
        $currency = $iso4217->getByNumeric($payCode);
378
        $this->setIsoCodeAlpha($currency['alpha3']);
379
380
        return $this;
381
    }
382
383
    /**
384
     * @return int|null
385
     */
386
    public function getRoundCondition(): ?int
387
    {
388
        return $this->roundCondition;
389
    }
390
391
    /**
392
     * @param int|null $roundCondition
393
     * @return Currency
394
     */
395
    public function setRoundCondition(?int $roundCondition)
396
    {
397
        $this->roundCondition = $roundCondition;
398
        return $this;
399
    }
400
401
    /**
402
     * @return int|null
403
     */
404
    public function getRoundDirection(): ?int
405
    {
406
        return $this->roundDirection;
407
    }
408
409
    /**
410
     * @param int|null $roundDirection
411
     * @return Currency
412
     */
413
    public function setRoundDirection(?int $roundDirection)
414
    {
415
        $this->roundDirection = $roundDirection;
416
        return $this;
417
    }
418
419
    /**
420
     * @return null|string
421
     */
422
    public function getRoundParam(): ?string
423
    {
424
        return $this->roundParam;
425
    }
426
427
    /**
428
     * @param null|string $roundParam
429
     * @return Currency
430
     */
431
    public function setRoundParam(?string $roundParam)
432
    {
433
        $this->roundParam = $roundParam;
434
        return $this;
435
    }
436
437
    /**
438
     * @return int|null
439
     */
440
    public function getRoundPrices(): ?int
441
    {
442
        return $this->roundPrices;
443
    }
444
445
    /**
446
     * @param int|null $roundPrices
447
     * @return Currency
448
     */
449
    public function setRoundPrices(?int $roundPrices)
450
    {
451
        $this->roundPrices = $roundPrices;
452
        return $this;
453
    }
454
455
    /**
456
     * @return null|string
457
     */
458
    public function getSymbol(): ?string
459
    {
460
        return $this->symbol;
461
    }
462
463
    /**
464
     * @param null|string $symbol
465
     * @return Currency
466
     */
467
    public function setSymbol(?string $symbol)
468
    {
469
        $this->symbol = $symbol;
470
        return $this;
471
    }
472
473
    /**
474
     * @return int|null
475
     */
476
    public function getSymbolAlign(): ?int
477
    {
478
        return $this->symbolAlign;
479
    }
480
481
    /**
482
     * @param int|null $symbolAlign
483
     * @return Currency
484
     */
485
    public function setSymbolAlign(?int $symbolAlign)
486
    {
487
        $this->symbolAlign = $symbolAlign;
488
        return $this;
489
    }
490
491
    /**
492
     * @return null|string
493
     */
494
    public function getText(): ?string
495
    {
496
        return $this->text;
497
    }
498
499
    /**
500
     * @param null|string $text
501
     * @return Currency
502
     */
503
    public function setText(?string $text)
504
    {
505
        $this->text = $text;
506
        return $this;
507
    }
508
509
    /**
510
     * @return int|null
511
     */
512
    public function getIsoCodeNumeric(): ?int
513
    {
514
        return $this->isoCodeNumeric;
515
    }
516
517
    /**
518
     * @param int|null $isoCodeNumeric
519
     * @return Currency
520
     */
521
    public function setIsoCodeNumeric(?int $isoCodeNumeric)
522
    {
523
        $this->isoCodeNumeric = $isoCodeNumeric;
524
        return $this;
525
    }
526
527
    /**
528
     * @return null|string
529
     */
530
    public function getIsoCodeAlpha(): ?string
531
    {
532
        return $this->isoCodeAlpha;
533
    }
534
535
    /**
536
     * @param null|string $isoCodeAlpha
537
     * @return Currency
538
     */
539
    public function setIsoCodeAlpha(?string $isoCodeAlpha)
540
    {
541
        $this->isoCodeAlpha = $isoCodeAlpha;
542
        return $this;
543
    }
544
}
545