DefaultRegionTrait.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace AlibabaCloud\Client\Traits;
  3. use AlibabaCloud\Client\AlibabaCloud;
  4. use AlibabaCloud\Client\Filter\ClientFilter;
  5. use AlibabaCloud\Client\Exception\ClientException;
  6. /**
  7. * Trait DefaultRegionTrait
  8. *
  9. * @package AlibabaCloud\Client\Traits
  10. *
  11. * @mixin AlibabaCloud
  12. */
  13. trait DefaultRegionTrait
  14. {
  15. /**
  16. * @var string|null Default RegionId
  17. */
  18. protected static $defaultRegionId;
  19. /**
  20. * @param $regionId
  21. *
  22. * @throws ClientException
  23. * @deprecated
  24. * @codeCoverageIgnore
  25. */
  26. public static function setGlobalRegionId($regionId)
  27. {
  28. self::setDefaultRegionId($regionId);
  29. }
  30. /**
  31. * @return string|null
  32. * @deprecated
  33. * @codeCoverageIgnore
  34. */
  35. public static function getGlobalRegionId()
  36. {
  37. return self::getDefaultRegionId();
  38. }
  39. /**
  40. * Get the default RegionId.
  41. *
  42. * @return string|null
  43. */
  44. public static function getDefaultRegionId()
  45. {
  46. return self::$defaultRegionId;
  47. }
  48. /**
  49. * Set the default RegionId.
  50. *
  51. * @param string $regionId
  52. *
  53. * @throws ClientException
  54. */
  55. public static function setDefaultRegionId($regionId)
  56. {
  57. self::$defaultRegionId = ClientFilter::regionId($regionId);
  58. }
  59. }