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


PHP Assertion::nullOrString方法代码示例

本文整理汇总了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;
 }
开发者ID:spomky-labs,项目名称:otphp,代码行数:11,代码来源:ParameterTrait.php

示例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;
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:20,代码来源:EncryptedSubjectIdentifier.php

示例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;
 }
开发者ID:old-town-gitlab-tools,项目名称:core,代码行数:23,代码来源:BaseReport.php

示例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;
 }
开发者ID:jonasrudolph,项目名称:php-component-user,代码行数:22,代码来源:UserRight.php

示例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;
 }
开发者ID:ben-gibson,项目名称:foursquare-venue-client,代码行数:31,代码来源:Detail.php

示例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;
 }
开发者ID:jonasrudolph,项目名称:php-component-user-propel,代码行数:19,代码来源:UserRightService.php

示例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;
 }
开发者ID:bweston92,项目名称:HumusAmqp,代码行数:27,代码来源:JsonRpcServer.php

示例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;
 }
开发者ID:domynation,项目名称:domynation-framework,代码行数:21,代码来源:SearchRequest.php

示例9: setDescription

 /**
  * Sets the description
  *
  * @param string $description
  */
 public function setDescription($description)
 {
     Assertion::nullOrString($description);
     $this->description = $description;
 }
开发者ID:indigophp,项目名称:service-application,代码行数:10,代码来源:Service.php

示例10: setRefreshToken

 /**
  * {@inheritdoc}
  */
 public function setRefreshToken($refresh_token)
 {
     Assertion::nullOrString($refresh_token);
     $this->refresh_token = $refresh_token;
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:8,代码来源:AccessToken.php

示例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);
 }
开发者ID:eleven-labs,项目名称:api-service,代码行数:12,代码来源:ApiService.php

示例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);
     }
 }
开发者ID:Zn4rK,项目名称:laravel-template,代码行数:12,代码来源:User.php

示例13: setSerializedMessage

 private function setSerializedMessage($serializedMessage)
 {
     Assertion::nullOrString($serializedMessage);
     $this->serializedMessage = $serializedMessage;
 }
开发者ID:ruudk,项目名称:Serialization,代码行数:5,代码来源:DefaultEnvelope.php

示例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);
     }
 }
开发者ID:metasyntactical,项目名称:inmemory-logger,代码行数:19,代码来源:LogQuery.php

示例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);
 }
开发者ID:spomky-labs,项目名称:php-aes-gcm,代码行数:27,代码来源:AESGCM.php


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