Configuration.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Aws\Endpoint\UseDualstackEndpoint;
  3. use Aws;
  4. use Aws\Endpoint\UseDualstackEndpoint\Exception\ConfigurationException;
  5. class Configuration implements ConfigurationInterface
  6. {
  7. private $useDualstackEndpoint;
  8. public function __construct($useDualstackEndpoint, $region)
  9. {
  10. $this->useDualstackEndpoint = Aws\boolean_value($useDualstackEndpoint);
  11. if (is_null($this->useDualstackEndpoint)) {
  12. throw new ConfigurationException("'use_dual_stack_endpoint' config option"
  13. . " must be a boolean value.");
  14. }
  15. if ($this->useDualstackEndpoint == true
  16. && (strpos($region, "iso-") !== false || strpos($region, "-iso") !== false)
  17. ) {
  18. throw new ConfigurationException("Dual-stack is not supported in ISO regions"); }
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function isUseDualstackEndpoint()
  24. {
  25. return $this->useDualstackEndpoint;
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function toArray()
  31. {
  32. return [
  33. 'use_dual_stack_endpoint' => $this->isUseDualstackEndpoint(),
  34. ];
  35. }
  36. }