*/ final readonly class CreateBrand implements UseCase { public function __construct( private BrandRepository $repository, private PictureStorage $pictureStorage, ) { } #[\Override] public function execute(BaseInput $input): Output { Assert::isInstanceOf($input, Input::class); if ($this->repository->existsByCode($input->code)) { throw new BrandCodeAlreadyExistsException($input->code); } $logoPath = $this->pictureStorage->store($input->logo); $brand = Brand::create( code: $input->code, name: $input->name, logo: $logoPath, rcs: $input->rcs, contact: $input->contact, ); $this->repository->save($brand); return new Output( name: $brand->name, code: $brand->code, logo: $brand->logo, rcs: $brand->rcs, contact: $brand->contact, createdAt: $brand->createdAt(), ); } }