| Conditions | 9 |
| Paths | 7 |
| Total Lines | 30 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function validate($qrBill, Constraint $constraint) |
||
| 14 | { |
||
| 15 | if (!$qrBill instanceof QrBill) { |
||
| 16 | return; |
||
| 17 | } |
||
| 18 | |||
| 19 | $creditorInformation = $qrBill->getCreditorInformation(); |
||
| 20 | $paymentReference = $qrBill->getPaymentReference(); |
||
| 21 | |||
| 22 | if (null === $creditorInformation || null === $paymentReference) { |
||
| 23 | return; |
||
| 24 | } |
||
| 25 | |||
| 26 | if (null === $creditorInformation->getIban() || null === $paymentReference->getType()) { |
||
|
1 ignored issue
–
show
|
|||
| 27 | return; |
||
| 28 | } |
||
| 29 | |||
| 30 | if ($creditorInformation->containsQrIban()) { |
||
| 31 | if ($qrBill->getPaymentReference()->getType() !== PaymentReference::TYPE_QR) { |
||
| 32 | $this->context->buildViolation($constraint->message) |
||
| 33 | ->setParameter('{{ referenceType }}', $paymentReference->getType()) |
||
| 34 | ->setParameter('{{ iban }}', $creditorInformation->getIban()) |
||
| 35 | ->addViolation(); |
||
| 36 | } |
||
| 37 | } else { |
||
| 38 | if ($qrBill->getPaymentReference()->getType() === PaymentReference::TYPE_QR) { |
||
| 39 | $this->context->buildViolation($constraint->message) |
||
| 40 | ->setParameter('{{ referenceType }}', $paymentReference->getType()) |
||
| 41 | ->setParameter('{{ iban }}', $creditorInformation->getIban()) |
||
| 42 | ->addViolation(); |
||
| 43 | } |
||
| 46 | } |