| 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
|
|||
| 9 | use Loevgaard\DandomainFoundation\Entity\Generated\CurrencyTrait; |
||
|
0 ignored issues
–
show
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. 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 bool|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 bool|null |
||
| 87 | * |
||
| 88 | * @ORM\Column(name="`default`", 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="integer") |
||
| 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="integer") |
||
| 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 | * |
||
| 208 | * @return Currency |
||
| 209 | */ |
||
| 210 | public function setId(int $id) |
||
| 211 | { |
||
| 212 | $this->id = $id; |
||
| 213 | |||
| 214 | return $this; |
||
| 215 | } |
||
| 216 | |||
| 217 | /** |
||
| 218 | * @return null|string |
||
| 219 | */ |
||
| 220 | public function getExternalId(): ?string |
||
| 221 | { |
||
| 222 | return $this->externalId; |
||
| 223 | } |
||
| 224 | |||
| 225 | /** |
||
| 226 | * @param null|string $externalId |
||
| 227 | * |
||
| 228 | * @return Currency |
||
| 229 | */ |
||
| 230 | public function setExternalId(?string $externalId) |
||
| 231 | { |
||
| 232 | $this->externalId = $externalId; |
||
| 233 | |||
| 234 | return $this; |
||
| 235 | 4 | } |
|
| 236 | |||
| 237 | 4 | /** |
|
| 238 | * @return null|string |
||
| 239 | 4 | */ |
|
| 240 | public function getCode(): ?string |
||
| 241 | { |
||
| 242 | return $this->code; |
||
| 243 | } |
||
| 244 | |||
| 245 | /** |
||
| 246 | * @param null|string $code |
||
| 247 | * |
||
| 248 | * @return Currency |
||
| 249 | */ |
||
| 250 | 2 | public function setCode(?string $code) |
|
| 251 | { |
||
| 252 | 2 | $this->code = $code; |
|
| 253 | |||
| 254 | 2 | return $this; |
|
| 255 | } |
||
| 256 | |||
| 257 | /** |
||
| 258 | * @return bool|null |
||
| 259 | */ |
||
| 260 | public function getDeActivated(): ?bool |
||
| 261 | { |
||
| 262 | return $this->deActivated; |
||
| 263 | } |
||
| 264 | |||
| 265 | /** |
||
| 266 | * @param bool|null $deActivated |
||
| 267 | * |
||
| 268 | * @return Currency |
||
| 269 | */ |
||
| 270 | public function setDeActivated(?bool $deActivated) |
||
| 271 | { |
||
| 272 | $this->deActivated = $deActivated; |
||
| 273 | |||
| 274 | return $this; |
||
| 275 | } |
||
| 276 | |||
| 277 | /** |
||
| 278 | * @return null|string |
||
| 279 | */ |
||
| 280 | public function getDelimiterDecimal(): ?string |
||
| 281 | { |
||
| 282 | return $this->delimiterDecimal; |
||
| 283 | } |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @param null|string $delimiterDecimal |
||
| 287 | * |
||
| 288 | * @return Currency |
||
| 289 | */ |
||
| 290 | public function setDelimiterDecimal(?string $delimiterDecimal) |
||
| 291 | { |
||
| 292 | $this->delimiterDecimal = $delimiterDecimal; |
||
| 293 | |||
| 294 | return $this; |
||
| 295 | } |
||
| 296 | |||
| 297 | /** |
||
| 298 | * @return null|string |
||
| 299 | */ |
||
| 300 | public function getDelimiterThousand(): ?string |
||
| 301 | { |
||
| 302 | return $this->delimiterThousand; |
||
| 303 | } |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @param null|string $delimiterThousand |
||
| 307 | * |
||
| 308 | * @return Currency |
||
| 309 | */ |
||
| 310 | public function setDelimiterThousand(?string $delimiterThousand) |
||
| 311 | { |
||
| 312 | $this->delimiterThousand = $delimiterThousand; |
||
| 313 | |||
| 314 | return $this; |
||
| 315 | } |
||
| 316 | |||
| 317 | /** |
||
| 318 | * @return int|null |
||
| 319 | */ |
||
| 320 | public function getFactor(): ?int |
||
| 321 | { |
||
| 322 | return $this->factor; |
||
| 323 | } |
||
| 324 | |||
| 325 | /** |
||
| 326 | * @param int|null $factor |
||
| 327 | * |
||
| 328 | * @return Currency |
||
| 329 | */ |
||
| 330 | public function setFactor(?int $factor) |
||
| 331 | { |
||
| 332 | $this->factor = $factor; |
||
| 333 | |||
| 334 | return $this; |
||
| 335 | } |
||
| 336 | |||
| 337 | /** |
||
| 338 | * @return null|string |
||
| 339 | */ |
||
| 340 | public function getIcon(): ?string |
||
| 341 | { |
||
| 342 | return $this->icon; |
||
| 343 | } |
||
| 344 | |||
| 345 | /** |
||
| 346 | * @param null|string $icon |
||
| 347 | * |
||
| 348 | * @return Currency |
||
| 349 | */ |
||
| 350 | public function setIcon(?string $icon) |
||
| 351 | { |
||
| 352 | $this->icon = $icon; |
||
| 353 | |||
| 354 | return $this; |
||
| 355 | } |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @return bool|null |
||
| 359 | */ |
||
| 360 | public function getDefault(): ?bool |
||
| 361 | { |
||
| 362 | return $this->default; |
||
| 363 | } |
||
| 364 | |||
| 365 | /** |
||
| 366 | * @param bool|null $default |
||
| 367 | * |
||
| 368 | * @return Currency |
||
| 369 | */ |
||
| 370 | public function setDefault(?bool $default) |
||
| 371 | { |
||
| 372 | $this->default = $default; |
||
| 373 | |||
| 374 | return $this; |
||
| 375 | } |
||
| 376 | |||
| 377 | /** |
||
| 378 | * @return int|null |
||
| 379 | */ |
||
| 380 | public function getPayCode(): ?int |
||
| 381 | { |
||
| 382 | return $this->payCode; |
||
| 383 | } |
||
| 384 | |||
| 385 | /** |
||
| 386 | * @param int|null $payCode |
||
| 387 | * |
||
| 388 | * @return Currency |
||
| 389 | */ |
||
| 390 | public function setPayCode(?int $payCode) |
||
| 391 | { |
||
| 392 | $this->payCode = $payCode; |
||
| 393 | $this->setIsoCodeNumeric($payCode); |
||
| 394 | |||
| 395 | if ($payCode) { |
||
|
0 ignored issues
–
show
The expression
$payCode of type integer|null is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like For 0 == false // true
0 == null // true
123 == false // false
123 == null // false
// It is often better to use strict comparison
0 === false // false
0 === null // false
Loading history...
|
|||
| 396 | $iso4217 = new ISO4217(); |
||
| 397 | $currency = $iso4217->getByNumeric($payCode); |
||
| 398 | $this->setIsoCodeAlpha($currency['alpha3']); |
||
| 399 | } |
||
| 400 | |||
| 401 | return $this; |
||
| 402 | } |
||
| 403 | |||
| 404 | /** |
||
| 405 | * @return int|null |
||
| 406 | */ |
||
| 407 | public function getRoundCondition(): ?int |
||
| 408 | { |
||
| 409 | return $this->roundCondition; |
||
| 410 | } |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @param int|null $roundCondition |
||
| 414 | * |
||
| 415 | * @return Currency |
||
| 416 | */ |
||
| 417 | public function setRoundCondition(?int $roundCondition) |
||
| 418 | { |
||
| 419 | $this->roundCondition = $roundCondition; |
||
| 420 | |||
| 421 | return $this; |
||
| 422 | } |
||
| 423 | |||
| 424 | /** |
||
| 425 | * @return int|null |
||
| 426 | */ |
||
| 427 | public function getRoundDirection(): ?int |
||
| 428 | { |
||
| 429 | return $this->roundDirection; |
||
| 430 | } |
||
| 431 | |||
| 432 | /** |
||
| 433 | * @param int|null $roundDirection |
||
| 434 | * |
||
| 435 | * @return Currency |
||
| 436 | */ |
||
| 437 | public function setRoundDirection(?int $roundDirection) |
||
| 438 | { |
||
| 439 | $this->roundDirection = $roundDirection; |
||
| 440 | |||
| 441 | return $this; |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * @return null|string |
||
| 446 | */ |
||
| 447 | public function getRoundParam(): ?string |
||
| 448 | { |
||
| 449 | return $this->roundParam; |
||
| 450 | } |
||
| 451 | |||
| 452 | /** |
||
| 453 | * @param null|string $roundParam |
||
| 454 | * |
||
| 455 | * @return Currency |
||
| 456 | */ |
||
| 457 | public function setRoundParam(?string $roundParam) |
||
| 458 | { |
||
| 459 | $this->roundParam = $roundParam; |
||
| 460 | |||
| 461 | return $this; |
||
| 462 | } |
||
| 463 | |||
| 464 | /** |
||
| 465 | * @return int|null |
||
| 466 | */ |
||
| 467 | public function getRoundPrices(): ?int |
||
| 468 | { |
||
| 469 | return $this->roundPrices; |
||
| 470 | } |
||
| 471 | |||
| 472 | /** |
||
| 473 | * @param int|null $roundPrices |
||
| 474 | 8 | * |
|
| 475 | * @return Currency |
||
| 476 | 8 | */ |
|
| 477 | public function setRoundPrices(?int $roundPrices) |
||
| 478 | { |
||
| 479 | $this->roundPrices = $roundPrices; |
||
| 480 | |||
| 481 | return $this; |
||
| 482 | 8 | } |
|
| 483 | |||
| 484 | 8 | /** |
|
| 485 | * @return null|string |
||
| 486 | 8 | */ |
|
| 487 | public function getSymbol(): ?string |
||
| 488 | { |
||
| 489 | return $this->symbol; |
||
| 490 | } |
||
| 491 | |||
| 492 | /** |
||
| 493 | * @param null|string $symbol |
||
| 494 | * |
||
| 495 | * @return Currency |
||
| 496 | */ |
||
| 497 | public function setSymbol(?string $symbol) |
||
| 498 | { |
||
| 499 | $this->symbol = $symbol; |
||
| 500 | |||
| 501 | return $this; |
||
| 502 | } |
||
| 503 | |||
| 504 | /** |
||
| 505 | * @return int|null |
||
| 506 | */ |
||
| 507 | public function getSymbolAlign(): ?int |
||
| 508 | { |
||
| 509 | return $this->symbolAlign; |
||
| 510 | } |
||
| 511 | |||
| 512 | /** |
||
| 513 | * @param int|null $symbolAlign |
||
| 514 | * |
||
| 515 | * @return Currency |
||
| 516 | */ |
||
| 517 | public function setSymbolAlign(?int $symbolAlign) |
||
| 518 | { |
||
| 519 | $this->symbolAlign = $symbolAlign; |
||
| 520 | |||
| 521 | return $this; |
||
| 522 | } |
||
| 523 | |||
| 524 | /** |
||
| 525 | * @return null|string |
||
| 526 | */ |
||
| 527 | public function getText(): ?string |
||
| 528 | { |
||
| 529 | return $this->text; |
||
| 530 | } |
||
| 531 | |||
| 532 | /** |
||
| 533 | * @param null|string $text |
||
| 534 | * |
||
| 535 | * @return Currency |
||
| 536 | */ |
||
| 537 | public function setText(?string $text) |
||
| 538 | { |
||
| 539 | $this->text = $text; |
||
| 540 | |||
| 541 | return $this; |
||
| 542 | } |
||
| 543 | |||
| 544 | /** |
||
| 545 | * @return int|null |
||
| 546 | */ |
||
| 547 | public function getIsoCodeNumeric(): ?int |
||
| 548 | { |
||
| 549 | return $this->isoCodeNumeric; |
||
| 550 | } |
||
| 551 | |||
| 552 | /** |
||
| 553 | * @param int|null $isoCodeNumeric |
||
| 554 | * |
||
| 555 | * @return Currency |
||
| 556 | */ |
||
| 557 | public function setIsoCodeNumeric(?int $isoCodeNumeric) |
||
| 558 | { |
||
| 559 | $this->isoCodeNumeric = $isoCodeNumeric; |
||
| 560 | |||
| 561 | return $this; |
||
| 562 | } |
||
| 563 | |||
| 564 | /** |
||
| 565 | * @return null|string |
||
| 566 | */ |
||
| 567 | 4 | public function getIsoCodeAlpha(): ?string |
|
| 568 | { |
||
| 569 | 4 | return $this->isoCodeAlpha; |
|
| 570 | } |
||
| 571 | |||
| 572 | /** |
||
| 573 | * @param null|string $isoCodeAlpha |
||
| 574 | * |
||
| 575 | * @return Currency |
||
| 576 | */ |
||
| 577 | 4 | public function setIsoCodeAlpha(?string $isoCodeAlpha) |
|
| 578 | { |
||
| 579 | 4 | $this->isoCodeAlpha = $isoCodeAlpha; |
|
| 580 | |||
| 581 | 4 | return $this; |
|
| 582 | } |
||
| 583 | } |
||
| 584 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths