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


PHP InvalidArgumentException::assertIntegerGreaterThanOrEqual方法代码示例

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


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

示例1: sequence_exponential

/**
 * Returns an infinite, traversable sequence that exponentially grows by given percentage
 *
 * @param integer $start
 * @param integer $percentage Integer between 1 and 100
 * @return ExponentialSequence
 * @throws InvalidArgumentException
 */
function sequence_exponential($start, $percentage)
{
    InvalidArgumentException::assertIntegerGreaterThanOrEqual($start, 1, __METHOD__, 1);
    InvalidArgumentException::assertIntegerGreaterThanOrEqual($percentage, 1, __METHOD__, 2);
    InvalidArgumentException::assertIntegerLessThanOrEqual($percentage, 100, __METHOD__, 2);
    return new ExponentialSequence($start, $percentage);
}
开发者ID:lstrojny,项目名称:functional-php,代码行数:15,代码来源:SequenceExponential.php

示例2: __construct

 public function __construct($start, $amount)
 {
     InvalidArgumentException::assertIntegerGreaterThanOrEqual($start, 0, __METHOD__, 1);
     InvalidArgumentException::assertInteger($amount, __METHOD__, 2);
     $this->start = $start;
     $this->amount = $amount;
 }
开发者ID:lstrojny,项目名称:functional-php,代码行数:7,代码来源:LinearSequence.php

示例3: retry

/**
 * Retry a callback until the number of retries are reached or the callback does no longer throw an exception
 *
 * @param callable $callback
 * @param integer $retries
 * @param Traversable|null $delaySequence Default: no delay between calls
 * @throws Exception Any exception thrown by the callback
 * @throws InvalidArgumentException
 * @return mixed Return value of the function
 */
function retry(callable $callback, $retries, Traversable $delaySequence = null)
{
    InvalidArgumentException::assertIntegerGreaterThanOrEqual($retries, 1, __FUNCTION__, 2);
    if ($delaySequence) {
        $delays = new AppendIterator();
        $delays->append(new InfiniteIterator($delaySequence));
        $delays->append(new InfiniteIterator(new ArrayIterator([0])));
        $delays = new LimitIterator($delays, $retries);
    } else {
        $delays = array_fill_keys(range(0, $retries), 0);
    }
    $retry = 0;
    foreach ($delays as $delay) {
        try {
            return $callback($retry, $delay);
        } catch (Exception $e) {
            if ($retry === $retries - 1) {
                throw $e;
            }
        }
        if ($delay > 0) {
            usleep($delay);
        }
        ++$retry;
    }
}
开发者ID:tdomarkas,项目名称:functional-php,代码行数:36,代码来源:Retry.php

示例4: __construct

 public function __construct($start, $percentage)
 {
     InvalidArgumentException::assertIntegerGreaterThanOrEqual($start, 1, __METHOD__, 1);
     InvalidArgumentException::assertIntegerGreaterThanOrEqual($percentage, 1, __METHOD__, 2);
     InvalidArgumentException::assertIntegerLessThanOrEqual($percentage, 100, __METHOD__, 2);
     $this->start = $start;
     $this->percentage = $percentage;
 }
开发者ID:lstrojny,项目名称:functional-php,代码行数:8,代码来源:ExponentialSequence.php

示例5: poll

/**
 * Retry a callback until it returns a truthy value or the timeout (in microseconds) is reached
 *
 * @param callable $callback
 * @param integer $timeout Timeout in microseconds
 * @param Traversable|null $delaySequence Default: no delay between calls
 * @throws InvalidArgumentException
 * @return boolean
 */
function poll(callable $callback, $timeout, Traversable $delaySequence = null)
{
    InvalidArgumentException::assertIntegerGreaterThanOrEqual($timeout, 0, __FUNCTION__, 2);
    $retry = 0;
    $delays = new AppendIterator();
    if ($delaySequence) {
        $delays->append(new InfiniteIterator($delaySequence));
    }
    $delays->append(new InfiniteIterator(new ArrayIterator([0])));
    $limit = microtime(true) + $timeout / 100000;
    foreach ($delays as $delay) {
        $value = $callback($retry, $delay);
        if ($value) {
            return $value;
        }
        if (microtime(true) > $limit) {
            return false;
        }
        if ($delay > 0) {
            usleep($delay);
        }
        ++$retry;
    }
}
开发者ID:tdomarkas,项目名称:functional-php,代码行数:33,代码来源:Poll.php

示例6: sequence_linear

/**
 * Returns an infinite, traversable sequence that linearly grows by given amount
 *
 * @param integer $start
 * @param integer $amount
 * @return Traversable
 */
function sequence_linear($start, $amount)
{
    InvalidArgumentException::assertIntegerGreaterThanOrEqual($start, 0, __FUNCTION__, 1);
    InvalidArgumentException::assertInteger($amount, __FUNCTION__, 2);
    return new LinearSequence($start, $amount);
}
开发者ID:lstrojny,项目名称:functional-php,代码行数:13,代码来源:SequenceLinear.php

示例7: sequence_constant

/**
 * Returns an infinite, traversable sequence of constant values
 *
 * @param integer $value
 * @return Traversable
 */
function sequence_constant($value)
{
    InvalidArgumentException::assertIntegerGreaterThanOrEqual($value, 0, __FUNCTION__, 1);
    return new InfiniteIterator(new ArrayIterator([$value]));
}
开发者ID:tdomarkas,项目名称:functional-php,代码行数:11,代码来源:SequenceConstant.php


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