本文整理汇总了PHP中Assert\Assertion::nullOrInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::nullOrInteger方法的具体用法?PHP Assertion::nullOrInteger怎么用?PHP Assertion::nullOrInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::nullOrInteger方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: withId
/**
* @param int|null $id
*
* @return UnfinishedUserRightSpec
*/
private static function withId($id)
{
Assertion::nullOrInteger($id);
if ($id === null) {
return self::hasUnauthorizedUser();
} else {
return new UnfinishedUserRightSpec(new ByIdUserSpec($id));
}
}
示例2: verify
/**
* If no timestamp is provided, the OTP is verified at the actual timestamp
* {@inheritdoc}
*/
public function verify($otp, $timestamp = null, $window = null)
{
Assertion::string($otp, 'The OTP must be a string');
Assertion::nullOrInteger($timestamp, 'The timestamp must be null or an integer');
Assertion::nullOrInteger($window, 'The window parameter must be null or an integer');
$timestamp = $this->getTimestamp($timestamp);
if (null === $window) {
return $this->compareOTP($this->at($timestamp), $otp);
}
return $this->verifyOtpWithWindow($otp, $timestamp, $window);
}
示例3: verify
/**
* If the counter is not provided, the OTP is verified at the actual counter.
*
* {@inheritdoc}
*/
public function verify($otp, $counter = null, $window = null)
{
Assertion::string($otp, 'The OTP must be a string');
Assertion::nullOrInteger($counter, 'The counter must be null or an integer');
Assertion::greaterOrEqualThan($counter, 0, 'The counter must be at least 0.');
Assertion::nullOrInteger($window, 'The window parameter must be null or an integer');
if (null === $counter) {
$counter = $this->getCounter();
} elseif ($counter < $this->getCounter()) {
return false;
}
return $this->verifyOtpWithWindow($otp, $counter, $window);
}
示例4: 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;
}
示例5: __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;
}
示例6: __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;
}
示例7: 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;
}
示例8: cleanup
/**
* Removes old project revision directories.
*
* @param Project $project Project instance
* @param int $copies Amount of copies to keep
*
* @return int Amount of deleted directories
*/
public function cleanup(Project $project, $copies = null)
{
Assertion::nullOrInteger($copies);
Assertion::nullOrMin($copies, 1);
if (is_null($copies)) {
$copies = $this->copies;
}
$projectDirectory = sprintf('%s/%s', $this->baseDirectory, $project->getName());
$finder = new Finder();
$finder->directories()->in($projectDirectory)->sort($this->getSortByDateAscClosure());
$directories = iterator_to_array($finder);
// calculate amount of directories to delete
$length = count($directories) - $copies;
if ($length < 0) {
$length = 0;
}
// extract directories to delete
$directories = array_slice($directories, 0, $length);
$fs = new Filesystem();
$fs->remove($directories);
$removedDirectoriesCount = count($directories);
$this->logger->debug(sprintf("Removing %s old copies in working directory.", $removedDirectoriesCount));
return $removedDirectoriesCount;
}