| Conditions | 4 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | 12 | public function validate($value, Constraint $constraint) |
|
| 34 | { |
||
| 35 | 12 | if (!$constraint instanceof BaseCurrency) { |
|
| 36 | 1 | throw new InvalidArgumentException(sprintf('Expected instance of "%s", got "%s".', BaseCurrency::class, get_class($constraint))); |
|
| 37 | } |
||
| 38 | |||
| 39 | 11 | if (null === $value) { |
|
| 40 | 2 | return; |
|
| 41 | } |
||
| 42 | |||
| 43 | 10 | if ($this->baseCurrencyCode !== $value) { |
|
| 44 | |||
| 45 | /** |
||
| 46 | * @var BaseCurrency $constraint |
||
| 47 | */ |
||
| 48 | 2 | $this->context |
|
| 49 | 2 | ->buildViolation($constraint->message) |
|
| 50 | 2 | ->setParameter('{{ base_currency_code }}', $this->baseCurrencyCode) |
|
| 51 | 2 | ->setParameter('{{ value }}', $value) |
|
| 52 | 2 | ->setTranslationDomain('runopencode_exchange_rate') |
|
| 53 | 2 | ->addViolation(); |
|
| 54 | } |
||
| 55 | 10 | } |
|
| 56 | } |
||
| 57 |