| 1 |
<?php |
| 2 |
|
| 3 |
namespace Dudlewebs\WPMCS\s3\Aws\EndpointDiscovery; |
| 4 |
|
| 5 |
class Configuration implements ConfigurationInterface |
| 6 |
{ |
| 7 |
private $cacheLimit; |
| 8 |
private $enabled; |
| 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("'cache_limit' value must be a positive integer."); |
| 14 |
} |
| 15 |
// Unparsable $enabled flag errs on the side of disabling endpoint discovery |
| 16 |
$this->enabled = \filter_var($enabled, \FILTER_VALIDATE_BOOLEAN); |
| 17 |
} |
| 18 |
/** |
| 19 |
* {@inheritdoc} |
| 20 |
*/ |
| 21 |
public function isEnabled() |
| 22 |
{ |
| 23 |
return $this->enabled; |
| 24 |
} |
| 25 |
/** |
| 26 |
* {@inheritdoc} |
| 27 |
*/ |
| 28 |
public function getCacheLimit() |
| 29 |
{ |
| 30 |
return $this->cacheLimit; |
| 31 |
} |
| 32 |
/** |
| 33 |
* {@inheritdoc} |
| 34 |
*/ |
| 35 |
public function toArray() |
| 36 |
{ |
| 37 |
return ['enabled' => $this->isEnabled(), 'cache_limit' => $this->getCacheLimit()]; |
| 38 |
} |
| 39 |
} |
| 40 |
|