Repository: symfony/symfony
File: src/Symfony/Bundle/SecurityBundle/Command/SecurityRoleHierarchyDumpCommand.php (PHP)

Code before:
                ),
            ])
            ->setHelp(<<<'USAGE'
                The <info>%command.name%</info> command dumps the role hierarchy in Mermaid format.

                <info>Mermaid</info>: %command.full_name% > roles.mmd
                <info>Mermaid with direction</info>: %command.full_name% --direction=BT > roles.mmd
                USAGE
            )
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);

        if (null === $this->roleHierarchy) {
            $io->getErrorStyle()->writeln('<comment>No role hierarchy is configured.</comment>');

            return Command::SUCCESS;
        }

        $direction = $input->getOption('direction');

        if (!MermaidDirectionEnum::tryFrom($direction)) {
            $io->getErrorStyle()->writeln('<error>Invalid direction. Available options: '.implode('|', $this->getAvailableDirections()).'</error>');

            return Command::FAILURE;
        }

        $dumper = new MermaidDumper();
        $mermaidOutput = $dumper->dump($this->roleHierarchy, MermaidDirectionEnum::from($direction));

        $output->writeln($mermaidOutput, OutputInterface::OUTPUT_RAW);

        return Command::SUCCESS;
    }

    /**
     * @return string[]
     */
    private function getAvailableDirections(): array
    {
        return array_map(fn ($case) => $case->value, MermaidDirectionEnum::cases());
    }
}


Review comment (suggestion):
```suggestion
            $io->getErrorStyle()->writeln(\sprintf('<error>Invalid direction, available options are "%s"</error>',  implode('"', $this->getAvailableDirections())));
```


Code after:
                ),
            ])
            ->setHelp(<<<'USAGE'
                The <info>%command.name%</info> command dumps the role hierarchy in Mermaid format.

                <info>Mermaid</info>: %command.full_name% > roles.mmd
                <info>Mermaid with direction</info>: %command.full_name% --direction=BT > roles.mmd
                USAGE
            )
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);

        if (null === $this->roleHierarchy) {
            $io->getErrorStyle()->writeln('<comment>No role hierarchy is configured.</comment>');

            return Command::SUCCESS;
        }

        $direction = $input->getOption('direction');

        if (!MermaidDirectionEnum::tryFrom($direction)) {
            $io->getErrorStyle()->writeln(\sprintf('<error>Invalid direction, available options are "%s"</error>', implode('"', $this->getAvailableDirections())));

            return Command::FAILURE;
        }

        $dumper = new MermaidDumper();
        $mermaidOutput = $dumper->dump($this->roleHierarchy, MermaidDirectionEnum::from($direction));

        $output->writeln($mermaidOutput, OutputInterface::OUTPUT_RAW);

        return Command::SUCCESS;
    }

    /**
     * @return string[]
     */
    private function getAvailableDirections(): array
    {
        return array_map(fn ($case) => $case->value, MermaidDirectionEnum::cases());
    }
}