| @@ 7-63 (lines=57) @@ | ||
| 4 | ||
| 5 | use Webmozart\Assert\Assert; |
|
| 6 | ||
| 7 | final class ChangeItemQuantity |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var string |
|
| 11 | */ |
|
| 12 | private $orderToken; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @var mixed |
|
| 16 | */ |
|
| 17 | private $itemIdentifier; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $quantity; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @param string $orderToken |
|
| 26 | * @param mixed $itemIdentifier |
|
| 27 | * @param int $quantity |
|
| 28 | */ |
|
| 29 | public function __construct($orderToken, $itemIdentifier, $quantity) |
|
| 30 | { |
|
| 31 | Assert::string($orderToken, 'Expected order token to be string, got %s'); |
|
| 32 | Assert::integer($quantity, 'Expected quantity to be integer, got %s'); |
|
| 33 | Assert::greaterThan($quantity, 0, 'Quantity should be greater than 0'); |
|
| 34 | ||
| 35 | $this->orderToken = $orderToken; |
|
| 36 | $this->itemIdentifier = $itemIdentifier; |
|
| 37 | $this->quantity = $quantity; |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * @return string |
|
| 42 | */ |
|
| 43 | public function orderToken() |
|
| 44 | { |
|
| 45 | return $this->orderToken; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @return mixed |
|
| 50 | */ |
|
| 51 | public function itemIdentifier() |
|
| 52 | { |
|
| 53 | return $this->itemIdentifier; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @return int |
|
| 58 | */ |
|
| 59 | public function quantity() |
|
| 60 | { |
|
| 61 | return $this->quantity; |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| @@ 7-64 (lines=58) @@ | ||
| 4 | ||
| 5 | use Webmozart\Assert\Assert; |
|
| 6 | ||
| 7 | final class PutSimpleItemToCart |
|
| 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 | * @param string $orderToken |
|
| 26 | * @param string $product |
|
| 27 | * @param int $quantity |
|
| 28 | */ |
|
| 29 | public function __construct($orderToken, $product, $quantity) |
|
| 30 | { |
|
| 31 | Assert::string($orderToken, 'Expected order token to be string, got %s'); |
|
| 32 | Assert::string($product, 'Expected product code to be string, got %s'); |
|
| 33 | Assert::integer($quantity, 'Expected quantity to be integer, got %s'); |
|
| 34 | Assert::greaterThan($quantity, 0, 'Quantity should be greater than 0'); |
|
| 35 | ||
| 36 | $this->orderToken = $orderToken; |
|
| 37 | $this->product = $product; |
|
| 38 | $this->quantity = $quantity; |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @return string |
|
| 43 | */ |
|
| 44 | public function orderToken() |
|
| 45 | { |
|
| 46 | return $this->orderToken; |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * @return string |
|
| 51 | */ |
|
| 52 | public function product() |
|
| 53 | { |
|
| 54 | return $this->product; |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * @return int |
|
| 59 | */ |
|
| 60 | public function quantity() |
|
| 61 | { |
|
| 62 | return $this->quantity; |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||