Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ProductPriceOutOfBoundsException | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| causer | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Alistaircol\Hta\Domain\Basket\Exceptions; |
| 6 | |
| 7 | use Alistaircol\Hta\Domain\Basket\Concerns\OfferInterface; |
| 8 | use Alistaircol\Hta\Domain\Basket\Concerns\ProductInterface; |
| 9 | use Alistaircol\Hta\Domain\Basket\PriceFormatter; |
| 10 | use OutOfBoundsException; |
| 11 | |
| 12 | class ProductPriceOutOfBoundsException extends OutOfBoundsException |
| 13 | { |
| 14 | public static function causer(ProductInterface $product): self |
| 15 | { |
| 16 | $id = $product->getId(); |
| 17 | $name = $product->getName(); |
| 18 | $price = (new PriceFormatter())->format($product->getPrice()); |
| 19 | |
| 20 | throw new self("The product ($id: $name) price is out of bounds. Given {$price} - it must be > 0."); |
| 21 | } |
| 22 | } |