當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。