addArgument( 'day', InputArgument::OPTIONAL, 'The day', new DateTimeImmutable(), new DateValidator() ); $this->addOption( 'lang', 'l', InputOption::VALUE_REQUIRED, 'The lang', null, new EnumValidator(Lang::class) ); $this->addOption( 'repeat', 'r', InputOption::VALUE_OPTIONAL, 'The number of repeat', 1, new IntegerValidator(1, null) ); } /** * @inheritDoc */ protected function execute (InputInterface $input, OutputInterface $output): int { $output->writeln('Command : ' . __CLASS__, OutputInterface::VERBOSITY_DEBUG); $text = ($input->getOption('lang') ?? Lang::English)->value; $repeat = $input->getOption('repeat'); /** @var DateTimeInterface $day */ $day = $input->getArgument('day'); if ((new DateTimeImmutable())->diff($day)->days === 0) { $text .= ' today'; } for ($curr = 0; $curr < $repeat; $curr++) { $output->writeln($text); } $output->writeln('FIN', ConsoleOutputWithMonolog::OPTION_SKIP_LOGGER); return Command::SUCCESS; } }