doConfigure(); $this ->addOptionWithDeprecatedFallback( self::START_DATE, 's', InputOption::VALUE_REQUIRED, $this->getStartDateDesc(self::START_DATE), ) ->addOptionWithDeprecatedFallback( self::END_DATE, 'e', InputOption::VALUE_REQUIRED, $this->getEndDateDesc(self::END_DATE), ); } protected function getStartDateOption(InputInterface $input, OutputInterface $output): ?Chronos { return $this->getDateOption($input, $output, self::START_DATE); } protected function getEndDateOption(InputInterface $input, OutputInterface $output): ?Chronos { return $this->getDateOption($input, $output, self::END_DATE); } private function getDateOption(InputInterface $input, OutputInterface $output, string $key): ?Chronos { $value = $this->getOptionWithDeprecatedFallback($input, $key); if (empty($value) || ! is_string($value)) { return null; } try { return Chronos::parse($value); } catch (Throwable $e) { $output->writeln(sprintf( '> Ignored provided "%s" since its value "%s" is not a valid date. <', $key, $value, )); if ($output->isVeryVerbose()) { $this->getApplication()?->renderThrowable($e, $output); } return null; } } abstract protected function doConfigure(): void; abstract protected function getStartDateDesc(string $optionName): string; abstract protected function getEndDateDesc(string $optionName): string; }