| 1 |
<?php |
| 2 |
namespace Aws\EndpointDiscovery; |
| 3 |
|
| 4 |
class Configuration implements ConfigurationInterface |
| 5 |
{ |
| 6 |
private $cacheLimit; |
| 7 |
private $enabled; |
| 8 |
|
| 9 |
public function __construct($enabled, $cacheLimit = 1000) |
| 10 |
{ |
| 11 |
$this->cacheLimit = filter_var($cacheLimit, FILTER_VALIDATE_INT); |
| 12 |
if ($this->cacheLimit == false || $this->cacheLimit < 1) { |
| 13 |
throw new \InvalidArgumentException( |
| 14 |
"'cache_limit' value must be a positive integer." |
| 15 |
); |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
$this->enabled = filter_var($enabled, FILTER_VALIDATE_BOOLEAN); |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public function isEnabled() |
| 26 |
{ |
| 27 |
return $this->enabled; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public function getCacheLimit() |
| 34 |
{ |
| 35 |
return $this->cacheLimit; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public function toArray() |
| 42 |
{ |
| 43 |
return [ |
| 44 |
'enabled' => $this->isEnabled(), |
| 45 |
'cache_limit' => $this->getCacheLimit() |
| 46 |
]; |
| 47 |
} |
| 48 |
} |