*/ final readonly class UpdateBrand implements UseCase, Transactional { public function __construct( private BrandRepository $repository, ) { } #[\Override] public function execute(BaseInput $input): Output { Assert::isInstanceOf($input, Input::class); $brand = $this->repository->findByCode($input->code); if (! $brand instanceof Brand) { return new BrandNotFound(); } if ($input->logo instanceof PicturePath) { $brand = $brand->changeLogo($input->logo); } if ($input->rcs instanceof Rcs) { $brand = $brand->changeRcs($input->rcs); } if ($input->contact instanceof Email) { $brand = $brand->changeContact($input->contact); } $this->repository->save($brand); return new BrandUpdated( name: $brand->name, code: $brand->code, logo: $brand->logo, rcs: $brand->rcs, contact: $brand->contact, ); } }