ldc-arcadia-api/src/Application/Arcadia/Usecase/IncoSheets/Find/FindIncoSheet.php

56 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace Application\Arcadia\Usecase\IncoSheets\Find;
use Application\Shared\Exceptions\NotFoundException;
use Domain\Ports\Directories\IncoSheetDirectory;
use Shared\DDD\Usecase\Input as BaseInput;
use Shared\DDD\Usecase\Usecase;
use Webmozart\Assert\Assert;
/** @implements Usecase<\Shared\DDD\Usecase\Input, \Shared\DDD\Usecase\Output> */
final readonly class FindIncoSheet implements Usecase
{
public function __construct(
private IncoSheetDirectory $directory
) {
}
#[\Override]
public function execute(BaseInput $input): Output
{
Assert::isInstanceOf($input, Input::class);
$incoSheet = $this->directory->find($input->id);
if ($incoSheet === null) {
throw NotFoundException::forEntity('IncoSheet', $input->id->value);
}
return new Output(
id: $incoSheet->id(),
name: $incoSheet->name,
label: $incoSheet->label,
description: $incoSheet->description,
allegations: $incoSheet->allegations,
sellArguments: $incoSheet->sellArguments,
preparationAdvices: $incoSheet->preparationAdvices,
tips: $incoSheet->tips,
sellFamilly: $incoSheet->sellFamilly,
ingredients: $incoSheet->ingredients,
portions: $incoSheet->portions,
allergens: $incoSheet->allergens,
brand: $incoSheet->brand,
isSeasonal: $incoSheet->isSeasonal,
weight: $incoSheet->weight,
nutriscore: $incoSheet->nutriscore,
storageCondition: $incoSheet->storageCondition,
additives: $incoSheet->additives,
compo: $incoSheet->compo,
createdAt: $incoSheet->createdAt,
updatedAt: $incoSheet->updatedAt,
);
}
}