Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Alistaircol\Hta\Domain\Basket\Concerns; |
| 6 | |
| 7 | use Alistaircol\Hta\Domain\Basket\DataTransferObjects\ProductInterfaceCollection; |
| 8 | |
| 9 | interface BasketInterface |
| 10 | { |
| 11 | /** |
| 12 | * Create a basket with an optional offer applied immediately. |
| 13 | * |
| 14 | * @param OfferInterface|null $offer |
| 15 | * @return BasketInterface |
| 16 | */ |
| 17 | public function create(?OfferInterface $offer = null): BasketInterface; |
| 18 | |
| 19 | /** |
| 20 | * Add a new product to the basket. |
| 21 | * |
| 22 | * @param ProductInterface $product |
| 23 | * @return BasketInterface |
| 24 | */ |
| 25 | public function add(ProductInterface $product): BasketInterface; |
| 26 | |
| 27 | /** |
| 28 | * Get a product by id from basket. |
| 29 | * |
| 30 | * @param string $id |
| 31 | * @return ProductInterface|null |
| 32 | */ |
| 33 | public function get(string $id): ?ProductInterface; |
| 34 | |
| 35 | /** |
| 36 | * Remove the given product from the basket. |
| 37 | * |
| 38 | * @param ProductInterface $product |
| 39 | * @return BasketInterface |
| 40 | */ |
| 41 | public function remove(ProductInterface $product): BasketInterface; |
| 42 | |
| 43 | /** |
| 44 | * Get all items in the basket. |
| 45 | * |
| 46 | * @return ProductInterfaceCollection |
| 47 | */ |
| 48 | public function getItems(): ProductInterfaceCollection; |
| 49 | |
| 50 | /** |
| 51 | * Apply an offer/discount to the basket. |
| 52 | * |
| 53 | * @param OfferInterface $offer |
| 54 | * @return BasketInterface |
| 55 | */ |
| 56 | public function applyOffer(OfferInterface $offer): BasketInterface; |
| 57 | |
| 58 | /** |
| 59 | * Get the offer applied to the basket. |
| 60 | * |
| 61 | * @return ?OfferInterface |
| 62 | */ |
| 63 | public function getAppliedOffer(): ?OfferInterface; |
| 64 | |
| 65 | /** |
| 66 | * Calculate the sum of all products price, with the offer applied (if applicable). |
| 67 | * |
| 68 | * The amount given is in the currency's minor unit, e.g. for GBP pence, for USD cents, etc. |
| 69 | * |
| 70 | * @return int |
| 71 | */ |
| 72 | public function getTotal(): int; |
| 73 | |
| 74 | /** |
| 75 | * Get the formatted price for the basket total, i.e. currency's minor unit. |
| 76 | * |
| 77 | * @param int $total |
| 78 | * @param string|null $iso4217 |
| 79 | * @return string |
| 80 | */ |
| 81 | public function getTotalFormatted(int $total, ?string $iso4217 = 'GBP'): string; |
| 82 | } |