Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • AbstractBackoffStrategy
  • AbstractErrorCodeBackoffStrategy
  • BackoffLogger
  • BackoffPlugin
  • CallbackBackoffStrategy
  • ConstantBackoffStrategy
  • CurlBackoffStrategy
  • ExponentialBackoffStrategy
  • HttpBackoffStrategy
  • LinearBackoffStrategy
  • ReasonPhraseBackoffStrategy
  • TruncatedBackoffStrategy

Interfaces

  • BackoffStrategyInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Plugin\Backoff;
 4: 
 5: use Guzzle\Common\Exception\InvalidArgumentException;
 6: use Guzzle\Http\Message\RequestInterface;
 7: use Guzzle\Http\Message\Response;
 8: use Guzzle\Http\Exception\HttpException;
 9: 
10: /**
11:  * Strategy that will invoke a closure to determine whether or not to retry with a delay
12:  */
13: class CallbackBackoffStrategy extends AbstractBackoffStrategy
14: {
15:     /**
16:      * @var \Closure|array|mixed Callable method to invoke
17:      */
18:     protected $callback;
19: 
20:     /**
21:      * @var bool Whether or not this strategy makes a retry decision
22:      */
23:     protected $decision;
24: 
25:     /**
26:      * @param \Closure|array|mixed     $callback Callable method to invoke
27:      * @param bool                     $decision Set to true if this strategy makes a backoff decision
28:      * @param BackoffStrategyInterface $next     The optional next strategy
29:      *
30:      * @throws InvalidArgumentException
31:      */
32:     public function __construct($callback, $decision, BackoffStrategyInterface $next = null)
33:     {
34:         if (!is_callable($callback)) {
35:             throw new InvalidArgumentException('The callback must be callable');
36:         }
37:         $this->callback = $callback;
38:         $this->decision = (bool) $decision;
39:         $this->next = $next;
40:     }
41: 
42:     /**
43:      * {@inheritdoc}
44:      */
45:     public function makesDecision()
46:     {
47:         return $this->decision;
48:     }
49: 
50:     /**
51:      * {@inheritdoc}
52:      */
53:     protected function getDelay($retries, RequestInterface $request, Response $response = null, HttpException $e = null)
54:     {
55:         return call_user_func($this->callback, $retries, $request, $response, $e);
56:     }
57: }
58: 
php-coveralls API documentation generated by ApiGen 2.8.0