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


PHP Assert::notEmpty方法代码示例

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


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

示例1: create

 /**
  * {@inheritdoc}
  */
 public static function create($body, DescriptionFactory $descriptionFactory = null, FqsenResolver $resolver = null, Context $context = null)
 {
     Assert::string($body);
     Assert::notEmpty($body);
     $parts = preg_split('/\\s+/Su', $body, 2);
     return new static($resolver->resolve($parts[0], $context), $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context));
 }
开发者ID:mbed67,项目名称:ReflectionDocBlock,代码行数:10,代码来源:Covers.php

示例2: getLastOptionValueElement

 /**
  * @return Element
  */
 private function getLastOptionValueElement()
 {
     $optionValues = $this->getElement('values');
     $items = $optionValues->findAll('css', 'div[data-form-collection="item"]');
     Assert::notEmpty($items);
     return end($items);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:10,代码来源:UpdatePage.php

示例3: getLastProvinceElement

 /**
  * @return Element
  */
 private function getLastProvinceElement()
 {
     $provinces = $this->getElement('provinces');
     $items = $provinces->findAll('css', 'div[data-form-collection="item"]');
     Assert::notEmpty($items);
     return end($items);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:10,代码来源:CreatePage.php

示例4: randomOne

 /**
  * @param RepositoryInterface $repository
  *
  * @return \Closure
  */
 public static function randomOne(RepositoryInterface $repository)
 {
     return function (Options $options) use($repository) {
         $objects = $repository->findAll();
         Assert::notEmpty($objects);
         return $objects[array_rand($objects)];
     };
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:13,代码来源:LazyOption.php

示例5: getProductVariantByNameAndProduct

 /**
  * @Transform /^"([^"]+)" variant of product "([^"]+)"$/
  */
 public function getProductVariantByNameAndProduct($variantName, $productName)
 {
     $products = $this->productRepository->findByName($productName, 'en_US');
     Assert::eq(1, count($products), sprintf('%d products has been found with name "%s".', count($products), $productName));
     $productVariants = $this->productVariantRepository->findByNameAndProduct($variantName, 'en_US', $products[0]);
     Assert::notEmpty($productVariants, sprintf('Product variant with name "%s" of product "%s" does not exist', $variantName, $productName));
     return $productVariants[0];
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:11,代码来源:ProductVariantContext.php

示例6: 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);
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:11,代码来源:OrderContext.php

示例7: __construct

 /**
  * Creates a new command name.
  *
  * @param string   $string  The command name.
  * @param string[] $aliases The alias names.
  */
 public function __construct($string, array $aliases = array())
 {
     Assert::string($string, 'The command name must be a string. Got: %s');
     Assert::notEmpty($string, 'The command name must not be empty.');
     Assert::regex($string, '~^[a-zA-Z0-9\\-]+$~', 'The command name must contain letters, digits and hyphens only. Got: "%s"');
     Assert::allString($aliases, 'The command aliases must be strings. Got: %s');
     Assert::allNotEmpty($aliases, 'The command aliases must not be empty.');
     Assert::allRegex($aliases, '~^[a-zA-Z0-9\\-]+$~', 'The command aliases must contain letters, digits and hyphens only. Got: "%s"');
     $this->string = $string;
     $this->aliases = $aliases;
 }
开发者ID:webmozart,项目名称:console,代码行数:17,代码来源:CommandName.php

示例8: randomOne

 /**
  * @param RepositoryInterface $repository
  *
  * @return \Closure
  */
 public static function randomOne(RepositoryInterface $repository)
 {
     return function (Options $options) use($repository) {
         $objects = $repository->findAll();
         if ($objects instanceof Collection) {
             $objects = $objects->toArray();
         }
         Assert::notEmpty($objects);
         return $objects[array_rand($objects)];
     };
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:16,代码来源:LazyOption.php

示例9: 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

示例10: 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

示例11: setBody

 /**
  * @param string $body
  */
 public function setBody($body)
 {
     \Webmozart\Assert\Assert::string($body);
     \Webmozart\Assert\Assert::notEmpty($body);
     $this->body = $body;
 }
开发者ID:tgalopin,项目名称:FOSMessage-demo,代码行数:9,代码来源:StartConversationModel.php

示例12: getColumnIndex

 /**
  * @param NodeElement $table
  * @param string $columnName
  *
  * @return int
  *
  * @throws \Exception If column was not found
  */
 private function getColumnIndex(NodeElement $table, $columnName)
 {
     $rows = $table->findAll('css', 'tr');
     Assert::notEmpty($rows, 'There are no rows!');
     /** @var NodeElement $firstRow */
     $firstRow = $rows[0];
     $columns = $firstRow->findAll('css', 'th,td');
     foreach ($columns as $index => $column) {
         /** @var NodeElement $column */
         if (0 === stripos($column->getText(), $columnName)) {
             return $index;
         }
     }
     throw new \InvalidArgumentException(sprintf('Column with name "%s" not found!', $columnName));
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:23,代码来源:TableAccessor.php

示例13: getLastCollectionItem

 /**
  * @param string $collection
  *
  * @return NodeElement
  */
 private function getLastCollectionItem($collection)
 {
     $items = $this->getCollectionItems($collection);
     Assert::notEmpty($items);
     return end($items);
 }
开发者ID:sylius,项目名称:sylius,代码行数:11,代码来源:CreatePage.php

示例14: __construct

 /**
  * @param PromotionEligibilityCheckerInterface[] $promotionEligibilityCheckers
  */
 public function __construct(array $promotionEligibilityCheckers)
 {
     Assert::notEmpty($promotionEligibilityCheckers);
     Assert::allIsInstanceOf($promotionEligibilityCheckers, PromotionEligibilityCheckerInterface::class);
     $this->promotionEligibilityCheckers = $promotionEligibilityCheckers;
 }
开发者ID:loic425,项目名称:Sylius,代码行数:9,代码来源:CompositePromotionEligibilityChecker.php

示例15: remove

 /**
  * {@inheritdoc}
  */
 public function remove($query, $language = 'glob')
 {
     if (null === $this->json) {
         $this->load();
     }
     $this->failUnlessGlob($language);
     $query = $this->sanitizePath($query);
     Assert::notEmpty(trim($query, '/'), 'The root directory cannot be removed.');
     $removed = $this->removeReferences($query);
     $this->flush();
     return $removed;
 }
开发者ID:puli,项目名称:repository,代码行数:15,代码来源:AbstractJsonRepository.php


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