Skip to content

Commit dedc199

Browse files
author
Alexey Babak
committed
fixed serialization
1 parent c694fab commit dedc199

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Product.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ public function getUnitPrice(): float
109109
/** @inheritDoc */
110110
public function setUnitPrice(float $unitPrice): self
111111
{
112+
if ($unitPrice <= 0) {
113+
throw new PaymentException('Нулевая цена не принимается');
114+
}
112115
$this->unitPrice = round($unitPrice, 2, PHP_ROUND_HALF_UP);
116+
113117
return $this;
114118
}
115119

@@ -122,7 +126,12 @@ public function getQuantity(): int
122126
/** @inheritDoc */
123127
public function setQuantity(int $quantity): self
124128
{
129+
if ($quantity <= 0) {
130+
throw new PaymentException('Нулевое количество не принимается');
131+
}
132+
125133
$this->quantity = $quantity;
134+
126135
return $this;
127136
}
128137

src/ProductInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function getSku() : string;
4040
* Установить Цена за 1 штуку, округление до копейки
4141
* @param float $unitPrice
4242
* @return $this Цена за 1 штуку
43+
* @throws PaymentException
4344
*/
4445
public function setUnitPrice(float $unitPrice) : self;
4546

@@ -53,6 +54,7 @@ public function getUnitPrice() : float;
5354
* Установить Количество
5455
* @param int $quantity Количество
5556
* @return $this
57+
* @throws PaymentException
5658
*/
5759
public function setQuantity(int $quantity) : self;
5860

0 commit comments

Comments
 (0)