shortUrlDataInput = new ShortUrlDataInput($this, longUrlAsOption: true); $this->shortUrlIdentifierInput = new ShortUrlIdentifierInput( $this, shortCodeDesc: 'The short code to edit', domainDesc: 'The domain to which the short URL is attached.', ); } protected function configure(): void { $this ->setName(self::NAME) ->setDescription('Edit an existing short URL'); } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $identifier = $this->shortUrlIdentifierInput->toShortUrlIdentifier($input); try { $shortUrl = $this->shortUrlService->updateShortUrl( $identifier, $this->shortUrlDataInput->toShortUrlEdition($input), ); $io->success(sprintf('Short URL "%s" properly edited', $this->stringifier->stringify($shortUrl))); return ExitCode::EXIT_SUCCESS; } catch (ShortUrlNotFoundException $e) { $io->error(sprintf('Short URL not found for "%s"', $identifier->__toString())); if ($io->isVerbose()) { $this->getApplication()?->renderThrowable($e, $io); } return ExitCode::EXIT_FAILURE; } } }