public static function keyExists($array, $key, $message = '') { if (!array_key_exists($key, $array)) { static::reportInvalidArgument(sprintf($message ?: 'Expected the key %s to exist.', static::valueToString($key))); } }
/** * {@inheritdoc} */ public function calculate(ProductVariantInterface $productVariant, array $context) { Assert::keyExists($context, 'channel'); $channelPricing = $productVariant->getChannelPricingForChannel($context['channel']); Assert::notNull($channelPricing); return $channelPricing->getPrice(); }