protected function generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null)
{
$placeHolders = ['<namespace>', '<version>', '<up>', '<down>'];
$replacements = [$configuration->getMigrationsNamespace(), $version, $up ? " " . implode("\n ", explode("\n", $up)) : null, $down ? " " . implode("\n ", explode("\n", $down)) : null];
$code = str_replace($placeHolders, $replacements, $this->getTemplate());
$code = preg_replace('/^ +$/m', '', $code);
$migrationDirectoryHelper = new MigrationDirectoryHelper($configuration);
$dir = $migrationDirectoryHelper->getMigrationDirectory();
$path = $dir . '/Version' . $version . '.php';
file_put_contents($path, $code);
if ($editorCmd = $input->getOption('editor-cmd')) {
proc_open($editorCmd . ' ' . escapeshellarg($path), [], $pipes);
}
return $path;
}