本文整理汇总了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]);
}
示例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;
}
示例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;
}
示例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));
}
示例5: toFileMakerValue
public function toFileMakerValue($value)
{
if (null === $value) {
return null;
}
Assertion::float($value);
return Decimal::fromFloat($value);
}
示例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;
}
示例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;
}
示例8: testValidFloat
public function testValidFloat()
{
Assertion::float(1.0);
Assertion::float(0.1);
Assertion::float(-1.1);
}
示例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;
}
示例10: applyDiscount
/**
* @param float $param
*/
public function applyDiscount($param)
{
Assertion::float($param);
$this->price = (double) $this->price * $param;
}
示例11: __construct
/**
* Cosntructor
*
* @param string $value [optional]
*/
public function __construct($value = null)
{
Assertion::float($value);
$this->value = $value;
}
示例12: isFloat
public function isFloat($value)
{
parent::float($value);
}
示例13: unbind
/**
* {@inheritdoc}
*/
public function unbind(string $key, $value) : Data
{
Assertion::float($value);
return Data::fromFlatArray([$key => (string) $value]);
}
示例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;
}