53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Cqs\Actions\Recipes\Create;
|
|
|
|
use App\Contracts\ActionInput;
|
|
use Domain\Models\ValueObjects\Products\ProductCategory;
|
|
use Domain\Models\ValueObjects\Recipes\ConsumptionTime;
|
|
use Domain\Models\ValueObjects\Recipes\Inspiration;
|
|
use Domain\Models\ValueObjects\Recipes\Season;
|
|
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
|
use Webmozart\Assert\Assert;
|
|
|
|
final readonly class CreateRecipeInput implements ActionInput
|
|
{
|
|
/**
|
|
* @param string[] $products
|
|
*/
|
|
public function __construct(
|
|
public string $name,
|
|
public string $seoTitle,
|
|
public string $seoDescription,
|
|
public bool $isPublished,
|
|
public ProductCategory $productCategory,
|
|
public ConsumptionTime $consomptionTime,
|
|
public Inspiration $inspiration,
|
|
public Season $season,
|
|
public ?string $description,
|
|
public ?string $details,
|
|
public string $ingredientsList,
|
|
public string $preparationSteps,
|
|
public ?string $tipsAndAdvices,
|
|
public ?StorageFilePath $picture,
|
|
public string $pictureAlt,
|
|
public string $pictureTitle,
|
|
public array $products = [],
|
|
) {
|
|
Assert::notEmpty($this->name);
|
|
Assert::notEmpty($this->seoTitle);
|
|
Assert::notEmpty($this->seoDescription);
|
|
Assert::notEmpty($this->ingredientsList);
|
|
Assert::notEmpty($this->preparationSteps);
|
|
Assert::notEmpty($this->pictureAlt);
|
|
Assert::notEmpty($this->pictureTitle);
|
|
|
|
when($this->description !== null, fn () => Assert::notEmpty($this->description));
|
|
when($this->details !== null, fn () => Assert::notEmpty($this->details));
|
|
when($this->tipsAndAdvices !== null, fn () => Assert::notEmpty($this->tipsAndAdvices));
|
|
|
|
Assert::allStringNotEmpty($this->products);
|
|
}
|
|
}
|