2026-09-30 10:24:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-11-10 14:28:00 +01:00
|
|
|
namespace App\Cqs\Actions\Basket;
|
2026-09-30 10:24:52 +02:00
|
|
|
|
|
|
|
|
use App\Contracts\Action;
|
|
|
|
|
use App\Contracts\ActionInput;
|
|
|
|
|
use Domain\Services\BasketService;
|
|
|
|
|
use Webmozart\Assert\Assert;
|
|
|
|
|
|
|
|
|
|
/**
|
2026-11-10 14:28:00 +01:00
|
|
|
* @implements \App\Contracts\Action<\App\Cqs\Actions\Basket\AddToBasketInput, void>
|
2026-09-30 10:24:52 +02:00
|
|
|
*/
|
|
|
|
|
final class AddToBasket implements Action
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly BasketService $basketService,
|
|
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[\Override]
|
|
|
|
|
public function __invoke(ActionInput $input): void
|
|
|
|
|
{
|
|
|
|
|
Assert::isInstanceOf($input, AddToBasketInput::class);
|
|
|
|
|
|
|
|
|
|
$this->basketService->add(
|
|
|
|
|
$input->productId,
|
|
|
|
|
$input->qty
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|