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


PHP Assertion::float方法代码示例

本文整理汇总了PHP中Assert\Assertion::float方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::float方法的具体用法?PHP Assertion::float怎么用?PHP Assertion::float使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assert\Assertion的用法示例。


在下文中一共展示了Assertion::float方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: customMetric

 public function customMetric($metricName, $value)
 {
     Assertion::string($metricName);
     Assertion::notBlank($metricName);
     Assertion::float($value);
     return $this->handle('newrelic_custom_metric', [$metricName, $value]);
 }
开发者ID:refinery29,项目名称:newrelic,代码行数:7,代码来源:Agent.php

示例2: __construct

 /**
  * @param float  $value
  * @param string $currency
  *
  * @throws \InvalidArgumentException
  */
 public function __construct($value, $currency)
 {
     Assertion::float($value);
     Assertion::greaterOrEqualThan($value, PriceInterface::VALUE_MIN);
     $this->value = $value;
     $this->currency = $currency;
 }
开发者ID:refinery29,项目名称:sitemap,代码行数:13,代码来源:Price.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param float $latitude The latitude.
  * @param float $longitude The longitude.
  */
 public function __construct($latitude, $longitude)
 {
     Assertion::float($latitude);
     Assertion::float($longitude);
     $this->latitude = $latitude;
     $this->longitude = $longitude;
 }
开发者ID:ben-gibson,项目名称:foursquare-venue-client,代码行数:13,代码来源:Coordinates.php

示例4: __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

示例5: toFileMakerValue

 public function toFileMakerValue($value)
 {
     if (null === $value) {
         return null;
     }
     Assertion::float($value);
     return Decimal::fromFloat($value);
 }
开发者ID:soliantconsulting,项目名称:simplefm,代码行数:8,代码来源:FloatType.php

示例6: __construct

 /**
  * @param string $name
  * @param float $price
  * @param string $currency
  */
 public function __construct($name, $price, $currency)
 {
     Assertion::notEmpty($name);
     Assertion::float($price);
     Assertion::notEmpty($currency);
     $this->name = $name;
     $this->price = $price;
     $this->currency = $currency;
 }
开发者ID:palya-framework,项目名称:palya,代码行数:14,代码来源:Product.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: testValidFloat

 public function testValidFloat()
 {
     Assertion::float(1.0);
     Assertion::float(0.1);
     Assertion::float(-1.1);
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:6,代码来源:AssertTest.php

示例9: handleInternalMessage

 /**
  * @param Envelope $envelope
  * @return DeliveryResult
  */
 protected function handleInternalMessage(Envelope $envelope) : DeliveryResult
 {
     if ('shutdown' === $envelope->getType()) {
         $this->logger->info('Shutdown message received');
         $this->shutdown();
         $result = DeliveryResult::MSG_ACK();
     } elseif ('reconfigure' === $envelope->getType()) {
         $this->logger->info('Reconfigure message received');
         try {
             list($idleTimeout, $target, $prefetchSize, $prefetchCount) = json_decode($envelope->getBody());
             if (is_numeric($idleTimeout)) {
                 $idleTimeout = (double) $idleTimeout;
             }
             Assertion::float($idleTimeout);
             Assertion::min($target, 0);
             Assertion::min($prefetchSize, 0);
             Assertion::min($prefetchCount, 0);
         } catch (\Throwable $e) {
             $this->logger->error('Exception during reconfiguration: ' . $e->getMessage());
             return DeliveryResult::MSG_REJECT();
         }
         $this->idleTimeout = $idleTimeout;
         $this->target = $target;
         $this->queue->getChannel()->qos($prefetchSize, $prefetchCount);
         $this->blockSize = $prefetchCount;
         $result = DeliveryResult::MSG_ACK();
     } elseif ('ping' === $envelope->getType()) {
         $this->logger->info('Ping message received');
         $result = DeliveryResult::MSG_ACK();
     } else {
         $this->logger->error('Invalid internal message: ' . $envelope->getType());
         $result = DeliveryResult::MSG_REJECT();
     }
     return $result;
 }
开发者ID:prolic,项目名称:HumusAmqp,代码行数:39,代码来源:AbstractConsumer.php

示例10: applyDiscount

 /**
  * @param float $param
  */
 public function applyDiscount($param)
 {
     Assertion::float($param);
     $this->price = (double) $this->price * $param;
 }
开发者ID:lzakrzewski,项目名称:tests-with-database-examples,代码行数:8,代码来源:Item.php

示例11: __construct

 /**
  * Cosntructor
  * 
  * @param string $value [optional]
  */
 public function __construct($value = null)
 {
     Assertion::float($value);
     $this->value = $value;
 }
开发者ID:jebbdomingo,项目名称:lifestutor3,代码行数:10,代码来源:Price.php

示例12: isFloat

 public function isFloat($value)
 {
     parent::float($value);
 }
开发者ID:loobee,项目名称:ddd,代码行数:4,代码来源:AssertionAdapter.php

示例13: unbind

 /**
  * {@inheritdoc}
  */
 public function unbind(string $key, $value) : Data
 {
     Assertion::float($value);
     return Data::fromFlatArray([$key => (string) $value]);
 }
开发者ID:dasprid,项目名称:formidable,代码行数:8,代码来源:FloatFormatter.php

示例14: withPriority

 /**
  * @param float $priority
  *
  * @throws \InvalidArgumentException
  *
  * @return static
  */
 public function withPriority($priority)
 {
     Assertion::float($priority);
     Assertion::greaterOrEqualThan($priority, UrlInterface::PRIORITY_MIN);
     Assertion::lessOrEqualThan($priority, UrlInterface::PRIORITY_MAX);
     Assertion::same($priority, round($priority, 1));
     $instance = clone $this;
     $instance->priority = $priority;
     return $instance;
 }
开发者ID:refinery29,项目名称:sitemap,代码行数:17,代码来源:Url.php


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