本文整理汇总了PHP中Webmozart\Assert\Assert::oneOf方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::oneOf方法的具体用法?PHP Assert::oneOf怎么用?PHP Assert::oneOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::oneOf方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMessages
/**
* {@inheritdoc}
*/
public function getMessages(ConversationInterface $conversation, $offset = 0, $limit = 20, $sortDirection = 'ASC')
{
Assert::integer($offset, '$offset expected an integer in Repository::getMessages(). Got: %s');
Assert::integer($limit, '$limit expected an integer in Repository::getMessages(). Got: %s');
Assert::oneOf(strtoupper($sortDirection), ['ASC', 'DESC'], '$sortDirection expected either ASC or DESC in Repository::getMessages(). Got: %s');
return $this->driver->findMessages($conversation, $offset, $limit, $sortDirection);
}
示例2: __construct
/**
* Creates the violation.
*
* @param int $code The violation code. One of the constants
* defined in this class.
* @param mixed $invalidValue The value that caused this violation.
* @param string $installerName The name of the validated installer.
* @param string|null $parameterName The name of the validated installer
* parameter or `null` if this is a generic
* error.
*/
public function __construct($code, $invalidValue, $installerName, $parameterName = null)
{
Assert::oneOf($code, self::$codes, 'The violation code %s is not valid.');
Assert::stringNotEmpty($installerName, 'The installer name must be a non-empty string. Got: %s');
Assert::nullOrStringNotEmpty($parameterName, 'The parameter name must be a non-empty string or null. Got: %s');
$this->code = $code;
$this->installerName = $installerName;
$this->parameterName = $parameterName;
$this->invalidValue = $invalidValue;
}
示例3: __construct
/**
* Creates a new package DTO.
*
* @param string $name The package name.
* @param string $installerName The name of the installer.
* @param string $installPath The absolute install path.
* @param string $state One of the STATE_* constants in this class.
*/
public function __construct($name, $installerName, $installPath, $state)
{
Assert::stringNotEmpty($name, 'The package name must be a non-empty string. Got: %s');
Assert::string($installerName, 'The installer name must be a string. Got: %s');
Assert::stringNotEmpty($installPath, 'The install path must be a non-empty string. Got: %s');
Assert::oneOf($state, self::$states, 'The package state must be one of %2$s. Got: %s');
$this->name = $name;
$this->installerName = $installerName;
$this->installPath = $installPath;
$this->state = $state;
}
示例4: moveLeaf
/**
* @param TaxonInterface $taxon
* @param string $direction
*
* @throws ElementNotFoundException
*/
private function moveLeaf(TaxonInterface $taxon, $direction)
{
Assert::oneOf($direction, [self::MOVE_DIRECTION_UP, self::MOVE_DIRECTION_DOWN]);
$leaves = $this->getLeaves();
foreach ($leaves as $leaf) {
if ($leaf->getText() === $taxon->getName()) {
$moveButton = $leaf->getParent()->find('css', sprintf('.sylius-taxon-move-%s', $direction));
$moveButton->click();
$moveButton->waitFor(5, function () use($moveButton) {
return $this->isOpen() && !$moveButton->hasClass('loading');
});
return;
}
}
throw new ElementNotFoundException($this->getDriver(), sprintf('Move %s button for %s taxon', $direction, $taxon->getName()));
}
示例5: assertAddressType
/**
* @param string $type
*/
private function assertAddressType($type)
{
$availableTypes = [self::TYPE_BILLING, self::TYPE_SHIPPING];
Assert::oneOf($type, $availableTypes, sprintf('There are only two available types %s, %s. %s given', self::TYPE_BILLING, self::TYPE_SHIPPING, $type));
}
示例6: setVerbosity
/**
* Sets the verbosity level of the output.
*
* @param int $verbosity One of the constants {@link NORMAL}, {@link VERBOSE},
* {@link VERY_VERBOSE} or {@link DEBUG}. Only output
* with the given verbosity level or smaller will be
* written out.
*/
public function setVerbosity($verbosity)
{
Assert::oneOf($verbosity, array(IO::NORMAL, IO::VERBOSE, IO::VERY_VERBOSE, IO::DEBUG), 'The verbosity must be one of IO::NORMAL, IO::VERBOSE, IO::VERY_VERBOSE and IO::DEBUG.');
$this->verbosity = (int) $verbosity;
}
示例7: iShouldBeAbleToShopUsingTheCurrency
/**
* @Then I should be able to shop using the :currencyCode currency
*/
public function iShouldBeAbleToShopUsingTheCurrency($currencyCode)
{
$this->homePage->open();
Assert::oneOf($currencyCode, $this->homePage->getAvailableCurrencies());
}
示例8: iShouldBeAbleToShopUsingTheLocale
/**
* @Then I should be able to shop using the :localeName locale
*/
public function iShouldBeAbleToShopUsingTheLocale($localeName)
{
$this->homePage->open();
Assert::oneOf($localeName, $this->homePage->getAvailableLocales());
}
示例9: setDefaultColumnAlignment
/**
* Returns the default column alignment.
*
* @param int $alignment One of the {@link Alignment} constants.
*
* @return static The current instance.
*/
public function setDefaultColumnAlignment($alignment)
{
Assert::oneOf($alignment, Alignment::all(), 'The default column alignment must be one of the Alignment constants. Got: %s');
$this->defaultColumnAlignment = $alignment;
return $this;
}
示例10: getDetail
/**
* @param string $name
*
* @return mixed
*/
public function getDetail($name)
{
Assert::oneOf($name, array_keys($this->details), 'ParsedKey::getDetail() expected one of: %2$s. Got: %s');
return $this->details[$name];
}
示例11: getResourceUrl
/**
* Find a resource URL.
*
* @param string $resource
*
* @return string
*/
public function getResourceUrl($resource)
{
Assert::oneOf($resource, self::getResourcesNames(), 'Resource type "%s" is not supported by the ACME server (supported: %2$s)');
return isset($this->serverResources[$resource]) ? $this->serverResources[$resource] : null;
}
示例12: setSearchedRelationType
/**
* Set searchedRelationType
*
* @param string $searchedRelationType
* @return User
*/
public function setSearchedRelationType($searchedRelationType)
{
Assert::oneOf($searchedRelationType, self::availableSearchingTypes());
$this->searchedRelationType = $searchedRelationType;
return $this;
}
示例13: setType
/**
* Set type
*
* @param string $type
* @return Course
*/
public function setType($type)
{
Assert::oneOf($type, [self::TYPE_C, self::TYPE_TD, self::TYPE_TP]);
$this->type = $type;
$this->refreshKey();
return $this;
}
示例14: setCellAlignment
/**
* Sets the cell alignment.
*
* @param int $alignment One of the {@link Alignment} constants.
*
* @return static The current instance.
*/
public function setCellAlignment($alignment)
{
Assert::oneOf($alignment, Alignment::all(), 'The cell alignment must be one of the Alignment constants. Got: %s');
$this->cellAlignment = $alignment;
return $this;
}