src/Command/CreateDatabaseDoctrineCommand.php
private function createDatabase(
        OutputInterface $output,
        string $connectionName,
        Connection $tmpConnection,
        string $dbName,
        bool $shouldNotCreateDatabase
    ): int {
        try {
            if ($shouldNotCreateDatabase) {
                $output->writeln(
                    sprintf(
                        '<info>Database <comment>%s</comment> for connection named <comment>%s</comment>'
                            .' already exists. Skipped.</info>',
                        $dbName,
                        $connectionName
                    )
                );
            } else {
                $tmpConnection->getSchemaManager()->createDatabase($dbName);
                $output->writeln(
                    sprintf(
                        '<info>Created database <comment>%s</comment>'
                             .' for connection named <comment>%s</comment>.</info>',
                        $dbName,
                        $connectionName
                    )
                );
            }

            return 0;
        } catch (\Exception $e) {
            $output->writeln(sprintf('<error>Could not create database <comment>%s</comment>.</error>', $dbName));
            $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));

            return 1;
        }
    }
private function createDatabase(
        OutputInterface $output,
        string $connectionName,
        Connection $tmpConnection,
        string $dbName,
        bool $shouldNotCreateDatabase
    ): int {
        try {
            if ($shouldNotCreateDatabase) {
                $output->writeln(
                    sprintf(
                        '<info>Database <comment>%s</comment> for connection named <comment>%s</comment>'
                            .' already exists. Skipped.</info>',
                        $dbName,
                        $connectionName
                    )
                );
            } else {
                $tmpConnection->getSchemaManager()->createDatabase($dbName);
                $output->writeln(
                    sprintf(
                        '<info>Created database <comment>%s</comment>'
                             .' for connection named <comment>%s</comment>.</info>',
                        $dbName,
                        $connectionName
                    )
                );
            }

            return 0;
        } catch (\Exception $e) {
            $output->writeln(sprintf('<error>Could not create database <comment>%s</comment>.</error>', $dbName));
            $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));

            return 1;
        }
    }
@param OutputInterface $output
@param string          $connectionName
@param Connection      $tmpConnection
@param string          $dbName
@param bool            $shouldNotCreateDatabase

@return int