addArgument('name', InputArgument::REQUIRED, 'O nome da classe de exceção (ex: InvalidPaymentException)'); } protected function execute(InputInterface $input, OutputInterface $output): int { $name = $input->getArgument('name'); if (!str_ends_with($name, 'Exception')) { $name .= 'Exception'; } $directory = dirname(__DIR__, 2) . '/Exceptions'; $filePath = $directory . '/' . $name . '.php'; if (file_exists($filePath)) { $output->writeln("A exceção '{$name}' já existe!"); return Command::FAILURE; } if (!is_dir($directory)) { mkdir($directory, 0755, true); } $year = date('Y'); $template = <<writeln("Exceção '{$name}' criada com sucesso em app/Exceptions/"); return Command::SUCCESS; } else { $output->writeln("Falha ao criar o arquivo da exceção."); return Command::FAILURE; } } }