34 lines
722 B
PHP
34 lines
722 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Queries\Basket;
|
||
|
|
|
||
|
|
use App\Contracts\Query;
|
||
|
|
use App\Contracts\QueryInput;
|
||
|
|
use App\Contracts\QueryInputEmpty;
|
||
|
|
use Domain\Models\Entities\Basket;
|
||
|
|
use Domain\Services\BasketService;
|
||
|
|
use Webmozart\Assert\Assert;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @implements \App\Contracts\Query<\App\Contracts\QueryInputEmpty, \Domain\Models\Entities\Basket>
|
||
|
|
*/
|
||
|
|
final readonly class GetBasketQuery implements Query
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private BasketService $basketService,
|
||
|
|
) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public function __invoke(QueryInput $input): Basket
|
||
|
|
{
|
||
|
|
Assert::isAOf(
|
||
|
|
$input,
|
||
|
|
QueryInputEmpty::class,
|
||
|
|
);
|
||
|
|
|
||
|
|
return $this->basketService->getBasket();
|
||
|
|
}
|
||
|
|
}
|