| Conditions | 7 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function validate($paymentMethod, Constraint $constraint): void |
||
| 17 | { |
||
| 18 | Assert::isInstanceOf($paymentMethod, PaymentMethodInterface::class); |
||
| 19 | Assert::isInstanceOf($constraint, Currency::class); |
||
| 20 | |||
| 21 | $gatewayConfig = $paymentMethod->getGatewayConfig(); |
||
| 22 | |||
| 23 | if (null === $gatewayConfig || $gatewayConfig->getFactoryName( |
||
| 24 | ) !== HTPayWayOffsiteGatewayFactory::FACTORY_NAME) { |
||
| 25 | return; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** @var ChannelInterface $channel */ |
||
| 29 | foreach ($paymentMethod->getChannels() as $channel) { |
||
| 30 | if ( |
||
| 31 | null === $channel->getBaseCurrency() || |
||
| 32 | false === in_array( |
||
| 33 | strtoupper($channel->getBaseCurrency()->getCode()), |
||
| 34 | HTPayWayFactoryInterface::CURRENCIES_AVAILABLE |
||
| 35 | ) |
||
| 36 | ) { |
||
| 37 | $message = isset($constraint->message) ? $constraint->message : null; |
||
| 38 | |||
| 39 | $this->context->buildViolation($message)->atPath('channels')->addViolation(); |
||
| 40 | |||
| 41 | return; |
||
| 42 | } |
||
| 46 |