| Total Complexity | 5 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class CartUseCaseApplication implements CartUseCase |
||
| 14 | { |
||
| 15 | public function __construct( |
||
| 16 | private CartRepository $repository, |
||
| 17 | private Prices $prices |
||
| 18 | ) { |
||
| 19 | } |
||
| 20 | |||
| 21 | public function add(string $cartId, string $productId, int $amount): void |
||
| 22 | { |
||
| 23 | $cart = $this->get($cartId); |
||
| 24 | $cart->add($productId, $amount); |
||
| 25 | $this->repository->add($cart); |
||
| 26 | } |
||
| 27 | |||
| 28 | public function detail(string $cartId): CartDetail |
||
| 29 | { |
||
| 30 | return $this->get($cartId)->calculate($this->prices); |
||
| 31 | } |
||
| 32 | |||
| 33 | private function get(string $cartId): Cart |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 |