本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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)];
};
}
示例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];
}
示例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);
}
示例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;
}
示例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)];
};
}
示例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());
}];
}
示例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);
}];
}
示例11: setBody
/**
* @param string $body
*/
public function setBody($body)
{
\Webmozart\Assert\Assert::string($body);
\Webmozart\Assert\Assert::notEmpty($body);
$this->body = $body;
}
示例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));
}
示例13: getLastCollectionItem
/**
* @param string $collection
*
* @return NodeElement
*/
private function getLastCollectionItem($collection)
{
$items = $this->getCollectionItems($collection);
Assert::notEmpty($items);
return end($items);
}
示例14: __construct
/**
* @param PromotionEligibilityCheckerInterface[] $promotionEligibilityCheckers
*/
public function __construct(array $promotionEligibilityCheckers)
{
Assert::notEmpty($promotionEligibilityCheckers);
Assert::allIsInstanceOf($promotionEligibilityCheckers, PromotionEligibilityCheckerInterface::class);
$this->promotionEligibilityCheckers = $promotionEligibilityCheckers;
}
示例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;
}