Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ProductPriceOutOfBoundsException
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 causer
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Alistaircol\Hta\Domain\Basket\Exceptions;
6
7use Alistaircol\Hta\Domain\Basket\Concerns\OfferInterface;
8use Alistaircol\Hta\Domain\Basket\Concerns\ProductInterface;
9use Alistaircol\Hta\Domain\Basket\PriceFormatter;
10use OutOfBoundsException;
11
12class 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}