当前位置: 首页>>代码示例>>PHP>>正文


PHP Assert::keyExists方法代码示例

本文整理汇总了PHP中Webmozart\Assert\Assert::keyExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::keyExists方法的具体用法?PHP Assert::keyExists怎么用?PHP Assert::keyExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Webmozart\Assert\Assert的用法示例。


在下文中一共展示了Assert::keyExists方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calculate

 /**
  * {@inheritdoc}
  */
 public function calculate(ProductVariantInterface $productVariant, array $context)
 {
     Assert::keyExists($context, 'channel');
     $channelPricing = $productVariant->getChannelPricingForChannel($context['channel']);
     Assert::notNull($channelPricing);
     return $channelPricing->getPrice();
 }
开发者ID:sylius,项目名称:core,代码行数:10,代码来源:ProductVariantPriceCalculator.php

示例2: preSubmit

 /**
  * @param FormEvent $event
  */
 public function preSubmit(FormEvent $event)
 {
     $attributeValue = $event->getData();
     Assert::keyExists($attributeValue, 'attribute', 'Cannot create an attribute value form on pre submit event without an "attribute" key in data.');
     $form = $event->getForm();
     $attribute = $this->attributeRepository->find($attributeValue['attribute']);
     $this->addValueField($form, $attribute);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:11,代码来源:BuildAttributeValueFormSubscriber.php

示例3: addListenerToSuite

 /**
  * @param Suite $suite
  * @param string $listenerName
  * @param array $listenerAttributes
  */
 private function addListenerToSuite(Suite $suite, $listenerName, array $listenerAttributes)
 {
     Assert::keyExists($listenerAttributes, 'options');
     $listener = $this->listenerRegistry->getListener($listenerName);
     $listenerOptions = $this->optionsProcessor->processConfiguration($listener, $listenerAttributes['options']);
     $listenerPriority = isset($listenerAttributes['priority']) ? $listenerAttributes['priority'] : 0;
     $suite->addListener($listener, $listenerOptions, $listenerPriority);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:13,代码来源:SuiteFactory.php

示例4: filter

 /**
  * {@inheritdoc}
  */
 public function filter(array $items, array $configuration)
 {
     if (!$this->isConfigured($configuration)) {
         return $items;
     }
     Assert::keyExists($configuration, 'channel');
     $filteredItems = [];
     foreach ($items as $item) {
         if ($this->isItemVariantInPriceRange($item->getVariant(), $configuration)) {
             $filteredItems[] = $item;
         }
     }
     return $filteredItems;
 }
开发者ID:sylius,项目名称:core,代码行数:17,代码来源:PriceRangeFilter.php

示例5: getSubscribedEvents

 /**
  * {@inheritDoc}
  */
 public function getSubscribedEvents()
 {
     return ['phpab.participation.variant_run' => function (array $options) {
         Assert::notEmpty($options, 'Array passed to closure cannot be empty.');
         Assert::keyExists($options, 1, 'Second parameter passed to closure must be instance of Bag.');
         Assert::isInstanceOf($options[1], 'PhpAb\\Test\\Bag', 'Second parameter passed to closure must be instance of Bag.');
         Assert::keyExists($options, 2, 'Third parameter passed to closure must be instance of VariantInterface.');
         Assert::isInstanceOf($options[2], 'PhpAb\\Variant\\VariantInterface', 'Third parameter passed to closure must be instance of VariantInterface.');
         /** @var TestInterface $test */
         $test = $options[1]->getTest();
         /** @var VariantInterface $chosenVariant */
         $chosenVariant = $options[2];
         // Call the add method
         $this->addParticipation($test->getIdentifier(), $chosenVariant->getIdentifier());
     }];
 }
开发者ID:phpab,项目名称:phpab,代码行数:19,代码来源:Generic.php

示例6: getEmailFromConfiguration

 /**
  * @param string $code
  *
  * @return EmailInterface
  */
 private function getEmailFromConfiguration($code)
 {
     Assert::keyExists($this->configuration, $code, sprintf('Email with code "%s" does not exist!', $code));
     /** @var EmailInterface $email */
     $email = $this->emailFactory->createNew();
     $configuration = $this->configuration[$code];
     $email->setCode($code);
     $email->setSubject($configuration['subject']);
     $email->setTemplate($configuration['template']);
     if (isset($configuration['enabled']) && false === $configuration['enabled']) {
         $email->setEnabled(false);
     }
     if (isset($configuration['sender']['name'])) {
         $email->setSenderName($configuration['sender']['name']);
     }
     if (isset($configuration['sender']['address'])) {
         $email->setSenderAddress($configuration['sender']['address']);
     }
     return $email;
 }
开发者ID:sylius,项目名称:mailer,代码行数:25,代码来源:EmailProvider.php

示例7: getSubscribedEvents

 /**
  * {@inheritDoc}
  */
 public function getSubscribedEvents()
 {
     return ['phpab.participation.variant_run' => function ($options) {
         Assert::notEmpty($options, 'Array passed to closure cannot be empty.');
         Assert::keyExists($options, 1, 'Second parameter passed to closure must be instance of Bag.');
         Assert::isInstanceOf($options[1], 'PhpAb\\Test\\Bag', 'Second parameter passed to closure must be instance of Bag.');
         Assert::keyExists($options, 2, 'Third parameter passed to closure must be instance of VariantInterface.');
         Assert::isInstanceOf($options[2], 'PhpAb\\Variant\\VariantInterface', 'Third parameter passed to closure must be instance of VariantInterface.');
         /** @var TestInterface $test */
         $test = $options[1]->getTest();
         Assert::keyExists($test->getOptions(), static::EXPERIMENT_ID, 'A Google Analytics Experiment Id must be set as options.');
         $experimentId = $test->getOptions()[static::EXPERIMENT_ID];
         /** @var VariantInterface $chosenVariant */
         $chosenVariant = $options[2];
         $variants = $test->getVariants();
         // Get the index number of the element
         $chosenIndex = array_search($chosenVariant->getIdentifier(), array_keys($variants));
         // Call the add method
         $this->addParticipation($experimentId, $chosenIndex);
     }];
 }
开发者ID:phpab,项目名称:phpab,代码行数:24,代码来源:Google.php

示例8: isConfigurationValid

 /**
  * {@inheritdoc}
  */
 protected function isConfigurationValid(array $configuration)
 {
     Assert::keyExists($configuration, 'amount');
     Assert::integer($configuration['amount']);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:8,代码来源:FixedDiscountAction.php

示例9: assertConfiguration

 /**
  * @param array $configuration
  * @param array $keys
  */
 protected function assertConfiguration($configuration, $keys)
 {
     foreach ($keys as $key) {
         Assert::keyExists($configuration, $key, 'Configuration key "%s" is required in action "' . $this->getName() . '"');
     }
 }
开发者ID:acmephp,项目名称:acmephp,代码行数:10,代码来源:AbstractAction.php

示例10: sortBy

 /**
  * {@inheritdoc}
  */
 public function sortBy($fieldName)
 {
     $sortableHeaders = $this->tableAccessor->getSortableHeaders($this->getElement('table'));
     Assert::keyExists($sortableHeaders, $fieldName, sprintf('Column "%s" is not sortable.', $fieldName));
     $sortableHeaders[$fieldName]->find('css', 'a')->click();
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:9,代码来源:IndexPage.php

示例11: getPrice

 /**
  * {@inheritdoc}
  */
 public function getPrice(ProductVariantInterface $productVariant, array $context)
 {
     Assert::keyExists($context, 'channel');
     return $this->productVariantPriceCalculator->calculate($productVariant, $context);
 }
开发者ID:sylius,项目名称:sylius,代码行数:8,代码来源:PriceHelper.php

示例12: assertValidDca

 /**
  * Assert that an valid dca is loaded.
  *
  * @param string $name Dca name.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 protected function assertValidDca($name)
 {
     Assert::keyExists($GLOBALS['TL_DCA'], $name);
     Assert::isArray($GLOBALS['TL_DCA'][$name]);
 }
开发者ID:netzmacht,项目名称:contao-toolkit,代码行数:14,代码来源:Manager.php


注:本文中的Webmozart\Assert\Assert::keyExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。