blob: aa370c4095af5c19b8f39b7e794901536228c199 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
namespace Aws\Retry;
use Aws\Retry\Exception\ConfigurationException;
class Configuration implements ConfigurationInterface
{
private $mode;
private $maxAttempts;
private $validModes = [
'legacy',
'standard',
'adaptive'
];
public function __construct($mode = 'legacy', $maxAttempts = 3)
{
$mode = strtolower($mode);
if (!in_array($mode, $this->validModes)) {
throw new ConfigurationException("'{$mode}' is not a valid mode."
. " The mode has to be 'legacy', 'standard', or 'adaptive'.");
}
if (!is_numeric($maxAttempts)
|| intval($maxAttempts) != $maxAttempts
|| $maxAttempts < 1
) {
throw new ConfigurationException("The 'maxAttempts' parameter has"
. " to be an integer >= 1.");
}
$this->mode = $mode;
$this->maxAttempts = intval($maxAttempts);
}
/**
* {@inheritdoc}
*/
public function getMode()
{
return $this->mode;
}
/**
* {@inheritdoc}
*/
public function getMaxAttempts()
{
return $this->maxAttempts;
}
/**
* {@inheritdoc}
*/
public function toArray()
{
return [
'mode' => $this->getMode(),
'max_attempts' => $this->getMaxAttempts(),
];
}
}
|