IndexName.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 Name object
  12. *
  13. * @api
  14. */
  15. class IndexName
  16. {
  17. /**
  18. * @var string
  19. */
  20. private $indexId;
  21. /**
  22. * @var Dimension[]
  23. */
  24. private $dimensions;
  25. /**
  26. * @var Alias
  27. */
  28. private $alias;
  29. /**
  30. * @param string $indexId
  31. * @param Dimension[] $dimensions
  32. * @param Alias $alias*
  33. * @throws LocalizedException
  34. */
  35. public function __construct(string $indexId, array $dimensions, Alias $alias)
  36. {
  37. foreach ($dimensions as $dimension) {
  38. if (!$dimension instanceof Dimension) {
  39. throw new LocalizedException(
  40. new Phrase('Dimension have to be instance of Dimension class.')
  41. );
  42. }
  43. }
  44. $this->indexId = $indexId;
  45. $this->dimensions = $dimensions;
  46. $this->alias = $alias;
  47. }
  48. /**
  49. * @return string
  50. */
  51. public function getIndexId(): string
  52. {
  53. return $this->indexId;
  54. }
  55. /**
  56. * @return Dimension[]
  57. */
  58. public function getDimensions(): array
  59. {
  60. return $this->dimensions;
  61. }
  62. /**
  63. * @return Alias
  64. */
  65. public function getAlias(): Alias
  66. {
  67. return $this->alias;
  68. }
  69. }