apiKeyService = $apiKeyService; parent::__construct(); } protected function configure(): void { $this ->setName(self::NAME) ->setDescription('Generates a new valid API key.') ->addOption( 'expirationDate', 'e', InputOption::VALUE_OPTIONAL, 'The date in which the API key should expire. Use any valid PHP format.' ); } protected function execute(InputInterface $input, OutputInterface $output): ?int { $expirationDate = $input->getOption('expirationDate'); $apiKey = $this->apiKeyService->create(isset($expirationDate) ? Chronos::parse($expirationDate) : null); (new SymfonyStyle($input, $output))->success(sprintf('Generated API key: "%s"', $apiKey)); return ExitCodes::EXIT_SUCCESS; } }