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