| @@ 9-82 (lines=74) @@ | ||
| 6 | ||
| 7 | use Webmozart\Assert\Assert; |
|
| 8 | ||
| 9 | final class PutOptionBasedConfigurableItemToCart |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var string |
|
| 13 | */ |
|
| 14 | private $orderToken; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @var string |
|
| 18 | */ |
|
| 19 | private $product; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var array |
|
| 23 | */ |
|
| 24 | private $options; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @var int |
|
| 28 | */ |
|
| 29 | private $quantity; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param string $orderToken |
|
| 33 | * @param string $product |
|
| 34 | * @param array $options |
|
| 35 | * @param int $quantity |
|
| 36 | */ |
|
| 37 | public function __construct($orderToken, $product, array $options, $quantity) |
|
| 38 | { |
|
| 39 | Assert::string($orderToken, 'Expected order token to be string, got %s'); |
|
| 40 | Assert::string($product, 'Expected product code to be string, got %s'); |
|
| 41 | Assert::notEmpty($options, 'Options array cannot be empty'); |
|
| 42 | Assert::integer($quantity, 'Expected quantity to be integer, got %s'); |
|
| 43 | Assert::greaterThan($quantity, 0, 'Quantity should be greater than 0'); |
|
| 44 | ||
| 45 | $this->orderToken = $orderToken; |
|
| 46 | $this->product = $product; |
|
| 47 | $this->options = $options; |
|
| 48 | $this->quantity = $quantity; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @return string |
|
| 53 | */ |
|
| 54 | public function orderToken() |
|
| 55 | { |
|
| 56 | return $this->orderToken; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @return string |
|
| 61 | */ |
|
| 62 | public function product() |
|
| 63 | { |
|
| 64 | return $this->product; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @return array |
|
| 69 | */ |
|
| 70 | public function options() |
|
| 71 | { |
|
| 72 | return $this->options; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @return int |
|
| 77 | */ |
|
| 78 | public function quantity() |
|
| 79 | { |
|
| 80 | return $this->quantity; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||
| @@ 9-82 (lines=74) @@ | ||
| 6 | ||
| 7 | use Webmozart\Assert\Assert; |
|
| 8 | ||
| 9 | final class PutVariantBasedConfigurableItemToCart |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var string |
|
| 13 | */ |
|
| 14 | private $orderToken; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @var string |
|
| 18 | */ |
|
| 19 | private $product; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var int |
|
| 23 | */ |
|
| 24 | private $quantity; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @var string |
|
| 28 | */ |
|
| 29 | private $productVariant; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param string $orderToken |
|
| 33 | * @param string $product |
|
| 34 | * @param string $productVariant |
|
| 35 | * @param int $quantity |
|
| 36 | */ |
|
| 37 | public function __construct($orderToken, $product, $productVariant, $quantity) |
|
| 38 | { |
|
| 39 | Assert::string($orderToken, 'Expected order token to be string, got %s'); |
|
| 40 | Assert::string($product, 'Expected product code to be string, got %s'); |
|
| 41 | Assert::string($productVariant, 'Expected product variant code to be string, got %s'); |
|
| 42 | Assert::integer($quantity, 'Expected quantity to be integer, got %s'); |
|
| 43 | Assert::greaterThan($quantity, 0, 'Quantity should be greater than 0'); |
|
| 44 | ||
| 45 | $this->orderToken = $orderToken; |
|
| 46 | $this->product = $product; |
|
| 47 | $this->quantity = $quantity; |
|
| 48 | $this->productVariant = $productVariant; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @return string |
|
| 53 | */ |
|
| 54 | public function orderToken() |
|
| 55 | { |
|
| 56 | return $this->orderToken; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @return string |
|
| 61 | */ |
|
| 62 | public function product() |
|
| 63 | { |
|
| 64 | return $this->product; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @return string |
|
| 69 | */ |
|
| 70 | public function productVariant() |
|
| 71 | { |
|
| 72 | return $this->productVariant; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @return int |
|
| 77 | */ |
|
| 78 | public function quantity() |
|
| 79 | { |
|
| 80 | return $this->quantity; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||