Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
OfferDiscountOutOfBoundsException
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 causer
100.00% covered (success)
100.00%
5 / 5
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 OutOfBoundsException;
9
10class OfferDiscountOutOfBoundsException extends OutOfBoundsException
11{
12    public static function causer(OfferInterface $offer): self
13    {
14        $name = $offer->getName();
15        $discount = $offer->getDiscountMultiplier();
16
17        throw new self(
18            "The offer ($name) discount (percentage to be subtracted) is out of bounds. "
19            . "Given {$discount} - it must be (0-100)."
20        );
21    }
22}