本文整理汇总了PHP中Assert\Assertion::integer方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::integer方法的具体用法?PHP Assertion::integer怎么用?PHP Assertion::integer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::integer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param int $x
* @param int $y
*/
public function __construct($x, $y)
{
Assertion::integer($x);
Assertion::integer($y);
$this->x = $x;
$this->y = $y;
}
示例2: findById
/**
* @param int $id
*
* @throws SubjectNotFoundException
*
* @return JusticeRecord|false
*/
public function findById($id)
{
Assertion::integer($id);
$crawler = $this->client->request('GET', sprintf(self::URL_SUBJECTS, $id));
$detailUrl = $this->extractDetailUrlFromCrawler($crawler);
if (false === $detailUrl) {
return false;
}
$people = [];
$crawler = $this->client->request('GET', $detailUrl);
$crawler->filter('.aunp-content .div-table')->each(function (Crawler $table) use(&$people) {
$title = $table->filter('.vr-hlavicka')->text();
try {
if ('jednatel: ' === $title) {
$person = JusticeJednatelPersonParser::parseFromDomCrawler($table);
$people[$person->getName()] = $person;
} elseif ('Společník: ' === $title) {
$person = JusticeSpolecnikPersonParser::parseFromDomCrawler($table);
$people[$person->getName()] = $person;
}
} catch (\Exception $e) {
}
});
return new JusticeRecord($people);
}
示例3: getKey
/**
* @param int $index
*
* @return \Jose\Object\JWKInterface
*/
public function getKey($index)
{
Assertion::integer($index, 'The index must be a positive integer.');
Assertion::greaterOrEqualThan($index, 0, 'The index must be a positive integer.');
Assertion::true($this->hasKey($index), 'Undefined index.');
return $this->getKeys()[$index];
}
示例4: setRadius
/**
* Set the radius in meters.
*
* @param int $meters
*
* @return self
*/
public function setRadius($meters)
{
Assertion::integer($meters);
Assertion::range($meters, 1, 100000);
$this->radius = $meters;
return $this;
}
示例5: __construct
/**
* Constructor
*
* @param AMQPQueue[] $queues
* @param float $idleTimeout in seconds
* @param int $waitTimeout in microseconds
* @param callable $deliveryCallback,
* @param callable|null $flushCallback,
* @param callable|null $errorCallback
* @throws Exception\InvalidArgumentException
*/
public function __construct(array $queues, $idleTimeout, $waitTimeout, callable $deliveryCallback, callable $flushCallback = null, callable $errorCallback = null)
{
Assertion::float($idleTimeout);
Assertion::integer($waitTimeout);
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']);
}
if (empty($queues)) {
throw new Exception\InvalidArgumentException('No queues given');
}
$q = [];
foreach ($queues as $queue) {
if (!$queue instanceof AMQPQueue) {
throw new Exception\InvalidArgumentException('Queue must be an instance of AMQPQueue, ' . is_object($queue) ? get_class($queue) : gettype($queue) . ' given');
}
if (null === $this->blockSize) {
$this->blockSize = $queue->getChannel()->getPrefetchCount();
}
$q[] = $queue;
}
$this->idleTimeout = (double) $idleTimeout;
$this->waitTimeout = (int) $waitTimeout;
$this->queues = new InfiniteIterator(new ArrayIterator($q));
}
示例6: changeQuantity
/**
* {@inheritdoc}
*/
public function changeQuantity($quantity)
{
Assertion::integer($quantity, 'Quantity must be an integer');
$quantity = $this->quantity + $quantity;
// Use this to make sure a proper integer check is done after addition
$this->setQuantity($quantity);
}
示例7: setPeriod
/**
* @param int $period
*
* @return self
*/
private function setPeriod($period)
{
Assertion::integer($period, 'Period must be at least 1.');
Assertion::greaterThan($period, 0, 'Period must be at least 1.');
$this->setParameter('period', $period);
return $this;
}
示例8: setLimit
/**
* Set the limit.
*
* @param int $limit
*
* @return self
*/
public function setLimit($limit)
{
Assertion::integer($limit);
Assertion::range($limit, 1, 50);
$this->limit = $limit;
return $this;
}
示例9: __construct
/**
* Initialise text item
*
* @param string $breakChar
* @param int $lines
*/
public function __construct($breakChar = ' ', $lines = 1)
{
Assertion::string($breakChar);
Assertion::integer($lines);
$this->breakChar = $breakChar;
$this->lines = $lines;
}
示例10: add
/**
* @param AddStorage $addStorage
*/
public function add(AddStorage $addStorage)
{
Assertion::integer($addStorage->storage);
Assertion::integer($addStorage->quota);
$storage = Storage::withUserDateUsageQuota(User::named($addStorage->name), new \DateTime(), Bytes::allocateUnits((int) $addStorage->storage), Quota::fromBytes(Bytes::allocateUnits((int) $addStorage->quota)));
$this->storageRepository->add($storage);
}
示例11: generate
/**
* @param int $width
* @param int $height
* @param array $shipSizes
* @return Fields
*/
public static function generate($width, $height, array $shipSizes)
{
Assertion::integer($width);
Assertion::integer($height);
Assertion::allInteger($shipSizes);
$elements = [];
for ($y = 0; $y < $height; $y++) {
for ($x = 0; $x < $width; $x++) {
$elements[] = Field::generate($x, $y);
}
}
$fields = Fields::create($elements);
foreach ($shipSizes as $shipSize) {
$attempts = 0;
while (true) {
if ($attempts == static::MAX_ATTEMPTS) {
throw new CannotPlaceShipOnGridException();
}
$direction = mt_rand(0, 1) == 0 ? 'right' : 'below';
$spot = Coords::create(mt_rand(0, $width - 1), mt_rand(0, $height - 1));
$endPoint = static::validEndpoint($fields, $spot, $shipSize, $direction);
if ($endPoint === null) {
$attempts++;
continue;
}
// If we end up here the ship can fit at the determined spot
$fields->place(Ship::create($spot, $endPoint));
break;
}
}
return $fields;
}
示例12: __construct
/**
* @param ClockInterface $clock
* @param integer $wait Wait for n milliseconds
* @param integer $timeout Timeout after n milliseconds
*/
public function __construct(ClockInterface $clock, $wait, $timeout)
{
Assertion::integer($wait);
Assertion::integer($timeout);
$this->clock = $clock;
$this->wait = static::millisecondsToMicroseconds($wait);
$this->timeout = static::millisecondsToMicroseconds($timeout);
}
示例13: toFileMakerValue
public function toFileMakerValue($value)
{
if (null === $value) {
return null;
}
Assertion::integer($value);
return Decimal::fromInteger($value);
}
示例14: __construct
/**
* ClientSecretBasic constructor.
*
* @param string $realm
* @param int $secret_lifetime
*/
public function __construct($realm, $secret_lifetime = 0)
{
Assertion::string($realm);
Assertion::integer($secret_lifetime);
Assertion::greaterOrEqualThan($secret_lifetime, 0);
$this->realm = $realm;
$this->secret_lifetime = $secret_lifetime;
}
示例15: __construct
/**
* ClientAssertionJwt constructor.
*
* @param \Jose\JWTLoaderInterface $jwt_loader
* @param \OAuth2\Exception\ExceptionManagerInterface $exception_manager
* @param int $secret_lifetime
*/
public function __construct(JWTLoaderInterface $jwt_loader, ExceptionManagerInterface $exception_manager, $secret_lifetime = 0)
{
$this->setJWTLoader($jwt_loader);
$this->setExceptionManager($exception_manager);
Assertion::integer($secret_lifetime);
Assertion::greaterOrEqualThan($secret_lifetime, 0);
$this->secret_lifetime = $secret_lifetime;
}