1: <?php
2:
3: namespace Guzzle\Plugin\Backoff;
4:
5: /**
6: * Strategy used to retry when certain error codes are encountered
7: */
8: abstract class AbstractErrorCodeBackoffStrategy extends AbstractBackoffStrategy
9: {
10: /**
11: * @var array Default cURL errors to retry
12: */
13: protected static $defaultErrorCodes = array();
14:
15: /**
16: * @var array Error codes that can be retried
17: */
18: protected $errorCodes;
19:
20: /**
21: * @param array $codes Array of codes that should be retried
22: * @param BackoffStrategyInterface $next The optional next strategy
23: */
24: public function __construct(array $codes = null, BackoffStrategyInterface $next = null)
25: {
26: $this->errorCodes = array_fill_keys($codes ?: static::$defaultErrorCodes, 1);
27: $this->next = $next;
28: }
29:
30: /**
31: * Get the default failure codes to retry
32: *
33: * @return array
34: */
35: public static function getDefaultFailureCodes()
36: {
37: return static::$defaultErrorCodes;
38: }
39:
40: /**
41: * {@inheritdoc}
42: */
43: public function makesDecision()
44: {
45: return true;
46: }
47: }
48: