本文整理汇总了PHP中Assert\Assertion::nullOrString方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::nullOrString方法的具体用法?PHP Assertion::nullOrString怎么用?PHP Assertion::nullOrString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::nullOrString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSecret
/**
* @param string|null $secret
*/
private function setSecret($secret)
{
Assertion::nullOrString($secret, 'The secret must be a string or null.');
if (null === $secret) {
$secret = trim(Base32::encode(random_bytes(32)), '=');
}
$this->parameters['secret'] = $secret;
}
示例2: __construct
/**
* EncryptedSubjectIdentifier constructor.
*
* @param string $pairwise_encryption_key
* @param string $algorithm
* @param null|string $iv
* @param string $salt
*/
public function __construct($pairwise_encryption_key, $algorithm, $iv, $salt)
{
Assertion::nullOrString($iv);
Assertion::string($salt);
Assertion::string($pairwise_encryption_key);
Assertion::string($algorithm);
Assertion::inArray($algorithm, openssl_get_cipher_methods(), sprintf('The algorithm "%s" is not supported.', $algorithm));
$this->pairwise_encryption_key = $pairwise_encryption_key;
$this->algorithm = $algorithm;
$this->salt = $salt;
$this->iv = $iv;
}
示例3: __construct
/**
* BaseReport constructor.
*
* @param BaseReportBuilder $builder
*
* @throws \Assert\AssertionFailedException
*/
public function __construct(BaseReportBuilder $builder)
{
$id = $builder->getId();
Assertion::uuid($id);
$this->id = $id;
$name = $builder->getName();
Assertion::string($name);
Assertion::notEmpty($name);
$this->name = $name;
$description = $builder->getDescription();
Assertion::nullOrString($description);
$this->setDescription($description);
$gitLab = $builder->getGitLab();
Assertion::isInstanceOf($gitLab, GitLab::class);
$this->gitLab = $gitLab;
}
示例4: __construct
/**
* @param int|null $userId
* @param int $rightId
* @param null|string $forObjectGroup
* @param null|string $withId
*/
public function __construct($userId, $rightId, $forObjectGroup, $withId)
{
Assertion::nullOrInteger($userId);
Assertion::integer($rightId);
Assertion::nullOrString($forObjectGroup);
//If there is no object group, there can not be an id
if ($forObjectGroup === null) {
Assertion::same($withId, null);
} else {
Assertion::nullOrString($withId);
}
$this->userId = $userId;
$this->rightId = $rightId;
$this->forObjectGroup = $forObjectGroup;
$this->withId = $withId;
}
示例5: __construct
/**
* Constructor.
*
* @param bool $verified
* @param \DateTimeImmutable|null $createdAt
* @param Photo\Photo $bestPhoto
* @param float|null $rating
* @param string|null $url
* @param int|null $hereNow
* @param string[] $tags
* @param int|null $likes
* @param \DateTimeZone|null $timeZone
*/
public function __construct($verified, \DateTimeImmutable $createdAt = null, Photo\Photo $bestPhoto = null, $rating = null, $url = null, $hereNow = null, $tags = [], $likes = null, \DateTimeZone $timeZone = null)
{
Assertion::boolean($verified);
Assertion::isArray($tags);
Assertion::nullOrInteger($likes);
Assertion::nullOrFloat($rating);
Assertion::nullOrString($url);
Assertion::nullOrInteger($hereNow);
$this->verified = $verified;
$this->rating = $rating;
$this->hereNow = $hereNow;
$this->url = $url;
$this->createdAt = $createdAt;
$this->timeZone = $timeZone;
$this->bestPhoto = $bestPhoto;
$this->tags = $tags;
$this->likes = $likes;
}
示例6: existsUserRight
public function existsUserRight($userId, $rightId, $forObject, $withId)
{
Assertion::nullOrInteger($userId);
Assertion::integer($rightId);
Assertion::nullOrString($forObject);
//If there is no forObject, there can not be an withId
if ($forObject === null) {
Assertion::same($withId, null);
} else {
Assertion::nullOrString($withId);
}
if ($userId !== null && !$this->userService->existsUserById($userId)) {
throw new UserDoesNotExistException();
}
if (!$this->rightService->existsRightById($rightId)) {
throw new RightNotFoundException();
}
return $this->getORMUserRight($userId, $rightId, $forObject, $withId) !== null;
}
示例7: __construct
/**
* Constructor
*
* @param AMQPQueue $queue
* @param float $idleTimeout in seconds
* @param int $waitTimeout in microseconds
* @param string|null $appId
*/
public function __construct(AMQPQueue $queue, $idleTimeout, $waitTimeout, $appId = null)
{
Assertion::float($idleTimeout);
Assertion::integer($waitTimeout);
Assertion::nullOrString($appId);
if (function_exists('pcntl_signal_dispatch')) {
$this->usePcntlSignalDispatch = true;
}
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGTERM, [$this, 'shutdown']);
pcntl_signal(SIGINT, [$this, 'shutdown']);
pcntl_signal(SIGHUP, [$this, 'shutdown']);
}
$this->blockSize = $queue->getChannel()->getPrefetchCount();
$this->idleTimeout = (double) $idleTimeout;
$this->waitTimeout = (int) $waitTimeout;
$this->queues = new InfiniteIterator(new ArrayIterator([$queue]));
$this->appId = $appId;
}
示例8: __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;
}
示例9: setDescription
/**
* Sets the description
*
* @param string $description
*/
public function setDescription($description)
{
Assertion::nullOrString($description);
$this->description = $description;
}
示例10: setRefreshToken
/**
* {@inheritdoc}
*/
public function setRefreshToken($refresh_token)
{
Assertion::nullOrString($refresh_token);
$this->refresh_token = $refresh_token;
}
示例11: getConfig
/**
* @param array $config
*/
private function getConfig(array $config)
{
$config = array_merge(self::DEFAULT_CONFIG, $config);
Assertion::boolean($config['returnResponse']);
Assertion::boolean($config['validateRequest']);
Assertion::boolean($config['validateResponse']);
Assertion::nullOrString($config['baseUri']);
return array_intersect_key($config, self::DEFAULT_CONFIG);
}
示例12: setRememberToken
/**
* @param null|string $value
*/
public function setRememberToken($value)
{
Assertion::nullOrString($value);
$oldValue = $this->rememberToken;
if ($oldValue !== $value) {
$this->rememberToken = $value;
$this->onPropertyChanged('rememberToken', $oldValue, $value);
}
}
示例13: setSerializedMessage
private function setSerializedMessage($serializedMessage)
{
Assertion::nullOrString($serializedMessage);
$this->serializedMessage = $serializedMessage;
}
示例14: validate
private function validate()
{
Assertion::nullOrString($this->logMessageRegExp);
Assertion::nullOrString($this->logMessageInString);
Assertion::nullOrString($this->logContextFuzzy);
Assertion::nullOrIsInstanceOf($this->logTimeLowerBounds, DateTimeInterface::class);
Assertion::nullOrIsInstanceOf($this->logTimeUpperBounds, DateTimeInterface::class);
Assertion::nullOrIsArray($this->logLevelList);
if (!is_null($this->logLevelList)) {
Assertion::notEmpty($this->logLevelList);
Assertion::allInArray($this->logLevelList, array_values((new ReflectionClass(LogLevel::class))->getConstants()));
}
if (!is_null($this->logMessageRegExp)) {
Assertion::true(RegexGuardFactory::getGuard()->isRegexValid($this->logMessageRegExp));
}
if (!is_null($this->logTimeLowerBounds) && !is_null($this->logTimeUpperBounds)) {
Assertion::false($this->logTimeLowerBounds->diff($this->logTimeUpperBounds)->invert);
}
}
示例15: decrypt
/**
* @param string $K Key encryption key
* @param string $IV Initialization vector
* @param string|null $C Data to encrypt (null for authentication)
* @param string|null $A Additional Authentication Data
* @param string $T Tag
*
* @return string
*/
public static function decrypt($K, $IV, $C, $A, $T)
{
Assertion::string($K, 'The key encryption key must be a binary string.');
$key_length = mb_strlen($K, '8bit') * 8;
Assertion::inArray($key_length, [128, 192, 256], 'Bad key encryption key length.');
Assertion::string($IV, 'The Initialization Vector must be a binary string.');
Assertion::nullOrString($C, 'The data to encrypt must be null or a binary string.');
Assertion::nullOrString($A, 'The Additional Authentication Data must be null or a binary string.');
$tag_length = self::getLength($T);
Assertion::integer($tag_length, 'Invalid tag length. Supported values are: 128, 120, 112, 104 and 96.');
Assertion::inArray($tag_length, [128, 120, 112, 104, 96], 'Invalid tag length. Supported values are: 128, 120, 112, 104 and 96.');
if (version_compare(PHP_VERSION, '7.1.0RC5') >= 0 && null !== $C) {
return self::decryptWithPHP71($K, $key_length, $IV, $C, $A, $T);
} elseif (class_exists('\\Crypto\\Cipher')) {
return self::decryptWithCryptoExtension($K, $key_length, $IV, $C, $A, $T, $tag_length);
}
return self::decryptWithPHP($K, $key_length, $IV, $C, $A, $T, $tag_length);
}