blob: dd7d8fba53bfc2d4622130cc32bc0985f2ed3004 (
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
|
<?php
namespace Aws\EndpointDiscovery;
class Configuration implements ConfigurationInterface
{
private $cacheLimit;
private $enabled;
public function __construct($enabled, $cacheLimit = 1000)
{
$this->cacheLimit = filter_var($cacheLimit, FILTER_VALIDATE_INT);
if ($this->cacheLimit == false || $this->cacheLimit < 1) {
throw new \InvalidArgumentException(
"'cache_limit' value must be a positive integer."
);
}
// Unparsable $enabled flag errs on the side of disabling endpoint discovery
$this->enabled = filter_var($enabled, FILTER_VALIDATE_BOOLEAN);
}
/**
* {@inheritdoc}
*/
public function isEnabled()
{
return $this->enabled;
}
/**
* {@inheritdoc}
*/
public function getCacheLimit()
{
return $this->cacheLimit;
}
/**
* {@inheritdoc}
*/
public function toArray()
{
return [
'enabled' => $this->isEnabled(),
'cache_limit' => $this->getCacheLimit()
];
}
}
|