35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Actions\ProductIncos;
|
||
|
|
|
||
|
|
use App\Contracts\ActionInput;
|
||
|
|
use App\Models\Product;
|
||
|
|
use Domain\Enums\Nutriscore;
|
||
|
|
use Domain\Models\ValueObjects\NutritionalValues;
|
||
|
|
use Webmozart\Assert\Assert;
|
||
|
|
|
||
|
|
final readonly class CreateProductIncoInput implements ActionInput
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
public Product $product,
|
||
|
|
public ?int $no_art = null,
|
||
|
|
public ?string $ingredients = null,
|
||
|
|
public ?string $preparation = null,
|
||
|
|
public ?string $servings = null,
|
||
|
|
public ?string $allergens = null,
|
||
|
|
public ?string $selling_argument = null,
|
||
|
|
public ?Nutriscore $nutriscore = null,
|
||
|
|
public ?string $nutriscore_args = null,
|
||
|
|
public NutritionalValues $nutrition = new NutritionalValues(),
|
||
|
|
) {
|
||
|
|
if ($this->no_art !== null) {
|
||
|
|
Assert::greaterThanEq($this->no_art, 1, 'Article number must be greater than or equal to 1.');
|
||
|
|
}
|
||
|
|
if ($this->servings !== null) {
|
||
|
|
Assert::maxLength($this->servings, 20, 'Servings cannot exceed 20 characters.');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|