Reservation.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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\InventoryReservations\Model;
  8. use Magento\InventoryReservationsApi\Model\ReservationInterface;
  9. /**
  10. * {@inheritdoc}
  11. *
  12. * @codeCoverageIgnore
  13. */
  14. class Reservation implements ReservationInterface
  15. {
  16. /**
  17. * @var int|null
  18. */
  19. private $reservationId;
  20. /**
  21. * @var int
  22. */
  23. private $stockId;
  24. /**
  25. * @var string
  26. */
  27. private $sku;
  28. /**
  29. * @var float
  30. */
  31. private $quantity;
  32. /**
  33. * @var string|null
  34. */
  35. private $metadata;
  36. /**
  37. * @param int|null $reservationId
  38. * @param int $stockId
  39. * @param string $sku
  40. * @param float $quantity
  41. * @param null $metadata
  42. */
  43. public function __construct(
  44. $reservationId,
  45. int $stockId,
  46. string $sku,
  47. float $quantity,
  48. $metadata = null
  49. ) {
  50. $this->reservationId = $reservationId;
  51. $this->stockId = $stockId;
  52. $this->sku = $sku;
  53. $this->quantity = $quantity;
  54. $this->metadata = $metadata;
  55. }
  56. /**
  57. * @inheritdoc
  58. */
  59. public function getReservationId(): ?int
  60. {
  61. return $this->reservationId === null ?
  62. null:
  63. (int)$this->reservationId;
  64. }
  65. /**
  66. * @inheritdoc
  67. */
  68. public function getStockId(): int
  69. {
  70. return $this->stockId;
  71. }
  72. /**
  73. * @inheritdoc
  74. */
  75. public function getSku(): string
  76. {
  77. return $this->sku;
  78. }
  79. /**
  80. * @inheritdoc
  81. */
  82. public function getQuantity(): float
  83. {
  84. return $this->quantity;
  85. }
  86. /**
  87. * @inheritdoc
  88. */
  89. public function getMetadata(): ?string
  90. {
  91. return $this->metadata;
  92. }
  93. }