本文整理汇总了PHP中Webmozart\Assert\Assert::notNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::notNull方法的具体用法?PHP Assert::notNull怎么用?PHP Assert::notNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::notNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: getCountryByName
/**
* @Transform /^country "([^"]+)"$/
* @Transform /^"([^"]+)" country$/
* @Transform /^"([^"]+)" as shipping country$/
*/
public function getCountryByName($countryName)
{
$countryCode = $this->countryNameConverter->convertToCode($countryName);
$country = $this->countryRepository->findOneBy(['code' => $countryCode]);
Assert::notNull($country, sprintf('Country with name "%s" does not exist', $countryName));
return $country;
}
示例3: create
/**
* Create the tag
*
* @param string $body Tag body
* @param DescriptionFactory $descriptionFactory The description factory
* @param Context|null $context The Context is used to resolve Types and FQSENs, although optional
* it is highly recommended to pass it. If you omit it then it is assumed that
* the DocBlock is in the global namespace and has no `use` statements.
*
* @return SleepTime
*/
public static function create($body, DescriptionFactory $descriptionFactory = null, Context $context = null)
{
Assert::integerish($body, self::MSG);
Assert::greaterThanEq($body, 0, self::MSG);
Assert::notNull($descriptionFactory);
return new static($descriptionFactory->create($body, $context));
}
示例4: iAmLoggedInAsAdministrator
/**
* @Given /^I am logged in as "([^"]+)" administrator$/
*/
public function iAmLoggedInAsAdministrator($email)
{
$user = $this->userRepository->findOneByEmail($email);
Assert::notNull($user);
$this->securityService->logIn($user);
$this->sharedStorage->set('admin', $user);
}
示例5: setPositionOfProduct
/**
* {@inheritdoc}
*/
public function setPositionOfProduct($productName, $position)
{
/** @var NodeElement $productsRow */
$productsRow = $this->getElement('table')->find('css', sprintf('tbody > tr:contains("%s")', $productName));
Assert::notNull($productsRow, 'There are no row with given product\'s name!');
$productsRow->find('css', '.sylius-product-taxon-position')->setValue($position);
}
示例6: create
/**
* Creates a new tag that represents any unknown tag type.
*
* @param string $body
* @param string $name
* @param DescriptionFactory $descriptionFactory
* @param Context $context
*
* @return static
*/
public static function create($body, $name = '', DescriptionFactory $descriptionFactory = null, Context $context = null)
{
Assert::string($body);
Assert::stringNotEmpty($name);
Assert::notNull($descriptionFactory);
$description = $descriptionFactory && $body ? $descriptionFactory->create($body, $context) : null;
return new static($name, $description);
}
示例7: update
/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException
*/
public function update(OrderInterface $order)
{
$currencyCode = $order->getCurrencyCode();
/** @var CurrencyInterface $currency */
$currency = $this->currencyRepository->findOneBy(['code' => $currencyCode]);
Assert::notNull($currency);
$order->setExchangeRate($currency->getExchangeRate());
}
示例8: create
/**
* {@inheritdoc}
*/
public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
{
Assert::string($body);
Assert::notNull($descriptionFactory);
$parts = preg_split('/\\s+/Su', $body, 2);
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
return new static($parts[0], $description);
}
示例9: getOrderByCustomer
/**
* @Transform /^this order made by "([^"]+)"$/
*/
public function getOrderByCustomer($email)
{
$customer = $this->customerRepository->findOneBy(['email' => $email]);
Assert::notNull($customer, sprintf('Cannot find customer with email %s.', $email));
$orders = $this->orderRepository->findByCustomer($customer);
Assert::notEmpty($orders);
return end($orders);
}
示例10: sendVerificationEmail
/**
* @param GenericEvent $event
*/
public function sendVerificationEmail(GenericEvent $event)
{
$customer = $event->getSubject();
Assert::isInstanceOf($customer, CustomerInterface::class);
$user = $customer->getUser();
Assert::notNull($user);
$this->handleUserVerificationToken($user);
}
示例11: createForPromotion
/**
* {@inheritdoc}
*/
public function createForPromotion($promotionId)
{
/** @var PromotionInterface $promotion */
Assert::notNull($promotion = $this->promotionRepository->find($promotionId), sprintf('Promotion with id %s does not exist.', $promotionId));
Assert::true($promotion->isCouponBased(), sprintf('Promotion with name %s is not coupon based.', $promotion->getName()));
$coupon = $this->factory->createNew();
$coupon->setPromotion($promotion);
return $coupon;
}
示例12: pressDelete
/**
* {@inheritdoc}
*/
public function pressDelete()
{
$this->getDocument()->pressButton('Delete');
$modal = $this->getDocument()->find('css', '#confirmation-modal');
Assert::notNull($modal, 'Confirmation modal not found!');
$confirmButton = $modal->find('css', 'a:contains(Delete)');
$this->waitForModalToAppear($modal);
$confirmButton->press();
}
示例13: prepareCaptureAction
/**
* @param Request $request
* @param $lastNewPaymentId
*
* @return Response
*/
public function prepareCaptureAction(Request $request, $lastNewPaymentId)
{
$configuration = $this->requestConfigurationFactory->create($this->paymentMetadata, $request);
$payment = $this->paymentRepository->find($lastNewPaymentId);
Assert::notNull($payment);
$request->getSession()->set('sylius_order_id', $payment->getOrder()->getId());
$captureToken = $this->getTokenFactory()->createCaptureToken($payment->getMethod()->getGateway(), $payment, $configuration->getParameters()->get('redirect[route]', null, true), $configuration->getParameters()->get('redirect[parameters]', [], true));
$view = View::createRedirect($captureToken->getTargetUrl());
return $this->viewHandler->handle($configuration, $view);
}
示例14: myDefaultAddressIsOf
/**
* @Given /^(my) default address is of "([^"]+)"$/
*/
public function myDefaultAddressIsOf(ShopUserInterface $user, $fullName)
{
list($firstName, $lastName) = explode(' ', $fullName);
/** @var AddressInterface $address */
$address = $this->addressRepository->findOneBy(['firstName' => $firstName, 'lastName' => $lastName]);
Assert::notNull($address, sprintf('The address of "%s" has not been found.', $fullName));
/** @var CustomerInterface $customer */
$customer = $user->getCustomer();
$this->setDefaultAddressOfCustomer($customer, $address);
}
示例15: generate
/**
* {@inheritdoc}
*/
public function generate($name, $parentId = null)
{
$taxonSlug = Transliterator::transliterate($name);
if (null === $parentId) {
return $taxonSlug;
}
/** @var TaxonInterface $parent */
$parent = $this->taxonRepository->find($parentId);
Assert::notNull($parent, sprintf('There is no parent taxon with id %d.', $parentId));
return $parent->getSlug() . self::SLUG_SEPARATOR . $taxonSlug;
}