Webmozart\Assert\Assert::keyExists PHP Method

keyExists() public static method

public static keyExists ( $array, $key, $message = '' )
    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)));
        }
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function calculate(ProductVariantInterface $productVariant, array $context)
 {
     Assert::keyExists($context, 'channel');
     $channelPricing = $productVariant->getChannelPricingForChannel($context['channel']);
     Assert::notNull($channelPricing);
     return $channelPricing->getPrice();
 }
All Usage Examples Of Webmozart\Assert\Assert::keyExists