當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Assertion::integer方法代碼示例

本文整理匯總了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;
 }
開發者ID:WeCamp,項目名稱:flyingliquourice,代碼行數:11,代碼來源:Coords.php

示例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);
 }
開發者ID:dfridrich,項目名稱:ares,代碼行數:32,代碼來源:Justice.php

示例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];
 }
開發者ID:spomky-labs,項目名稱:jose,代碼行數:12,代碼來源:BaseJWKSet.php

示例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;
 }
開發者ID:ben-gibson,項目名稱:foursquare-venue-client,代碼行數:14,代碼來源:CanSupportRadius.php

示例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));
 }
開發者ID:bweston92,項目名稱:HumusAmqp,代碼行數:40,代碼來源:MultiQueueConsumer.php

示例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);
 }
開發者ID:indigophp,項目名稱:cart,代碼行數:10,代碼來源:Quantity.php

示例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;
 }
開發者ID:spomky-labs,項目名稱:otphp,代碼行數:12,代碼來源:TOTP.php

示例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;
 }
開發者ID:ben-gibson,項目名稱:foursquare-venue-client,代碼行數:14,代碼來源:CanBeLimited.php

示例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;
 }
開發者ID:thehereward,項目名稱:cli-menu,代碼行數:13,代碼來源:LineBreakItem.php

示例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);
 }
開發者ID:arnovr,項目名稱:owncloud-statistics,代碼行數:10,代碼來源:AddStorageHandler.php

示例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;
 }
開發者ID:WeCamp,項目名稱:flyingliquourice,代碼行數:38,代碼來源:FieldsGenerator.php

示例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);
 }
開發者ID:matthiasnoback,項目名稱:phpunit-asynchronicity,代碼行數:13,代碼來源:Timeout.php

示例13: toFileMakerValue

 public function toFileMakerValue($value)
 {
     if (null === $value) {
         return null;
     }
     Assertion::integer($value);
     return Decimal::fromInteger($value);
 }
開發者ID:soliantconsulting,項目名稱:simplefm,代碼行數:8,代碼來源:IntegerType.php

示例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;
 }
開發者ID:spomky-labs,項目名稱:oauth2-server-library,代碼行數:14,代碼來源:ClientSecretBasic.php

示例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;
 }
開發者ID:spomky-labs,項目名稱:oauth2-server-library,代碼行數:15,代碼來源:ClientAssertionJwt.php


注:本文中的Assert\Assertion::integer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。