Exception
11 months ago
Configuration.php
11 months ago
ConfigurationInterface.php
11 months ago
ConfigurationProvider.php
11 months ago
EndpointDiscoveryMiddleware.php
11 months ago
EndpointList.php
11 months ago
Configuration.php
49 lines
| 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 | // Unparsable $enabled flag errs on the side of disabling endpoint discovery |
| 19 | $this->enabled = filter_var($enabled, FILTER_VALIDATE_BOOLEAN); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * {@inheritdoc} |
| 24 | */ |
| 25 | public function isEnabled() |
| 26 | { |
| 27 | return $this->enabled; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * {@inheritdoc} |
| 32 | */ |
| 33 | public function getCacheLimit() |
| 34 | { |
| 35 | return $this->cacheLimit; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * {@inheritdoc} |
| 40 | */ |
| 41 | public function toArray() |
| 42 | { |
| 43 | return [ |
| 44 | 'enabled' => $this->isEnabled(), |
| 45 | 'cache_limit' => $this->getCacheLimit() |
| 46 | ]; |
| 47 | } |
| 48 | } |
| 49 |