本文整理汇总了PHP中Assert\Assertion::choice方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::choice方法的具体用法?PHP Assertion::choice怎么用?PHP Assertion::choice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::choice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string $direction
* @param int $days
*/
public function __construct($direction, $days)
{
Assertion::integerish($days);
Assertion::choice($direction, [self::DIRECTION_PAST, self::DIRECTION_FUTURE]);
$this->direction = $direction;
$this->days = (int) $days;
}
示例2: withResolution
/**
* @param string $resolution
*
* @throws \InvalidArgumentException
*
* @return static
*/
public function withResolution($resolution)
{
$choices = [PriceInterface::RESOLUTION_HD, PriceInterface::RESOLUTION_SD];
Assertion::choice($resolution, $choices);
$instance = clone $this;
$instance->resolution = $resolution;
return $instance;
}
示例3: withAllowEmbed
/**
* @param string $allowEmbed
*
* @throws \InvalidArgumentException
*
* @return static
*/
public function withAllowEmbed($allowEmbed)
{
$choices = [PlayerLocationInterface::ALLOW_EMBED_NO, PlayerLocationInterface::ALLOW_EMBED_YES];
Assertion::choice($allowEmbed, $choices);
$instance = clone $this;
$instance->allowEmbed = $allowEmbed;
return $instance;
}
示例4: __construct
/**
* Constructor.
*
* @param Identifier $identifier
* @param \DateTimeImmutable $createdAt
* @param string $url
* @param string $visibility
*/
public function __construct(Identifier $identifier, \DateTimeImmutable $createdAt, $url, $visibility)
{
Assertion::choice($visibility, static::$visibilityEnum);
Assertion::url($url);
$this->identifier = $identifier;
$this->createdAt = $createdAt;
$this->url = $url;
$this->visibility = $visibility;
}
示例5: __construct
/**
* @param int $gender
* @param string $firstName
* @param string $lastName
* @param string $email
*/
public function __construct($gender, $firstName, $lastName, $email)
{
Assertion::choice($gender, [self::GENDER_MALE, self::GENDER_FEMALE]);
Assertion::notEmpty($firstName);
Assertion::notEmpty($lastName);
Assertion::email($email);
$this->gender = $gender;
$this->firstName = $firstName;
$this->lastName = $lastName;
$this->email = $email;
}
示例6: __construct
/**
* @param string $result
* @param Coords $target
* @param Coords $startPoint
* @param Coords $endPoint
*/
private function __construct($result, Coords $target, Coords $startPoint = null, Coords $endPoint = null)
{
Assertion::choice($result, [static::HIT, static::MISS, static::SANK, static::WIN]);
if (in_array($result, [static::SANK, static::WIN])) {
Assertion::notNull($startPoint);
Assertion::notNull($endPoint);
}
$this->result = $result;
$this->startPoint = $startPoint;
$this->endPoint = $endPoint;
$this->target = $target;
}
示例7: array
/**
* Create a Config.
*
* @param string $sender Sender code to use.
* @param string $wsdl WSDL file to use (local path or URL), null means default depending on the debug mode.
* @param int $timeoutSec (Optional) Timeout in seconds, null means no timeout.
* @param string $operatingMode (Optional) Operating mode, default is "P" for production. "D" = Development, "T" = Test.
* @param array $soapClientOptions (Optional) Options for SoapClient.
* @param string $receiver (Optional) Receiver code to use, default: YELLOWCUBE.
*/
function __construct($sender, $wsdl = null, $timeoutSec = null, $operatingMode = 'P', array $soapClientOptions = array(), $receiver = 'YELLOWCUBE')
{
Assertion::notEmpty($sender, 'Sender must be set.');
Assertion::nullOrNotEmpty($wsdl, 'WSDL must be set.');
Assertion::nullOrInteger($timeoutSec, 'Timeout must be null or an integer in seconds.');
Assertion::choice($operatingMode, array('T', 'D', 'P'), 'Operating mode must be "T", "D" or "P".');
Assertion::notEmpty($receiver, 'Receiver must be set.');
$this->sender = $sender;
$this->wsdl = $wsdl;
$this->timeoutSec = $timeoutSec;
$this->operatingMode = $operatingMode;
$this->soapClientOptions = $soapClientOptions;
$this->receiver = $receiver;
}
示例8: __construct
/**
* @param UuidInterface $id
* @param int $type
* @param string $street
* @param string $streetNumber
* @param string $postalCode
* @param string $city
* @param string $state
* @param string $country
* @param string $phone
*/
public function __construct(UuidInterface $id, $type, $street, $streetNumber, $postalCode, $city, $state, $country, $phone)
{
Assertion::uuid($id->toString());
Assertion::choice($type, [self::TYPE_BILLING, self::TYPE_SHIPPING]);
Assertion::notEmpty($street);
Assertion::notEmpty($streetNumber);
Assertion::notEmpty($postalCode);
Assertion::notEmpty($city);
Assertion::notEmpty($state);
Assertion::notEmpty($country);
Assertion::notEmpty($phone);
$this->id = $id;
$this->type = $type;
$this->street = $street;
$this->streetNumber = $streetNumber;
$this->postalCode = $postalCode;
$this->city = $city;
$this->state = $state;
$this->country = $country;
$this->phone = $phone;
}
示例9: __construct
public function __construct($filters, $offset, $limit, $sortField, $sortOrder, $isPaginated)
{
Assertion::isArray($filters, "Invalid filters");
Assertion::integerish($limit, "Invalid limit");
Assertion::integerish($offset, "Invalid offset");
Assertion::nullOrString($sortField, "Invalid sort field");
Assertion::choice($sortOrder, [null, self::ORDER_ASC, self::ORDER_DESC], "Invalid sort order");
Assertion::boolean($isPaginated, "Invalid value for isPaginated");
if ($limit < 0) {
throw new \InvalidArgumentException("Invalid limit");
}
if ($offset < 0) {
throw new \InvalidArgumentException("Invalid offset");
}
$this->filters = $filters;
$this->offset = (int) $offset;
$this->limit = (int) $limit;
$this->sortField = $sortField;
$this->sortOrder = $sortOrder;
$this->isPaginated = (bool) $isPaginated;
}
示例10: withLive
/**
* @param string $live
*
* @throws \InvalidArgumentException
*
* @return static
*/
public function withLive($live)
{
$choices = [VideoInterface::LIVE_NO, VideoInterface::LIVE_YES];
Assertion::choice($live, $choices);
$instance = clone $this;
$instance->live = $live;
return $instance;
}
示例11: __construct
/**
* @param string $relationship
*
* @throws \InvalidArgumentException
*/
public function __construct($relationship)
{
$choices = [PlatformInterface::RELATIONSHIP_ALLOW, PlatformInterface::RELATIONSHIP_DENY];
Assertion::choice($relationship, $choices);
$this->relationship = $relationship;
}
示例12: __construct
/**
* @param string $value
*/
private function __construct($value)
{
Guard::choice($value, $this->possibleValues());
$this->value = $value;
}
示例13: __construct
private function __construct($type)
{
Assertion::choice($type, ['read', 'write']);
$this->type = $type;
}
示例14: withChangeFrequency
/**
* @param string $changeFrequency
*
* @throws \InvalidArgumentException
*
* @return static
*/
public function withChangeFrequency($changeFrequency)
{
$choices = [UrlInterface::CHANGE_FREQUENCY_ALWAYS, UrlInterface::CHANGE_FREQUENCY_HOURLY, UrlInterface::CHANGE_FREQUENCY_DAILY, UrlInterface::CHANGE_FREQUENCY_WEEKLY, UrlInterface::CHANGE_FREQUENCY_MONTHLY, UrlInterface::CHANGE_FREQUENCY_YEARLY, UrlInterface::CHANGE_FREQUENCY_NEVER];
Assertion::choice($changeFrequency, $choices);
$instance = clone $this;
$instance->changeFrequency = $changeFrequency;
return $instance;
}
示例15: __construct
/**
* @param string $algo
*/
public function __construct($algo)
{
Assertion::choice($algo, hash_algos());
$this->algo = $algo;
}