Alias.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\InventoryMultiDimensionalIndexerApi\Model;
  8. use Magento\Framework\Exception\LocalizedException;
  9. use Magento\Framework\Phrase;
  10. /**
  11. * Index Alias object
  12. *
  13. * @api
  14. */
  15. class Alias
  16. {
  17. /**
  18. * Replica index alias
  19. */
  20. const ALIAS_REPLICA = 'replica';
  21. /**
  22. * Main index alias
  23. */
  24. const ALIAS_MAIN = 'main';
  25. /**
  26. * One of self::ALIAS_*
  27. *
  28. * @var string
  29. */
  30. private $value;
  31. /**
  32. * @param string $value One of self::ALIAS_*
  33. * @throws LocalizedException
  34. */
  35. public function __construct(string $value)
  36. {
  37. if ($value !== self::ALIAS_REPLICA && $value !== self::ALIAS_MAIN) {
  38. throw new LocalizedException(new Phrase('Wrong value %value for alias', ['value' => $value]));
  39. }
  40. $this->value = $value;
  41. }
  42. /**
  43. * @return string One of self::ALIAS_*
  44. */
  45. public function getValue(): string
  46. {
  47. return $this->value;
  48. }
  49. }