/** * @param Configuration $configuration * @param bool $create * @param bool $update * @param null $up * @param null $down * * @return string */ public function generate(Configuration $configuration, $create = false, $update = false, $up = null, $down = null) { $stub = $this->getStub($create, $update); $contents = $this->locator->locate($stub)->get(); $contents = $this->replacer->replace($contents, $this->variables, [$configuration->getMigrationsNamespace(), $configuration->getNamingStrategy()->getClassName(), $this->getTableName($create, $update), $up ? $this->tabbedNewLine($up) : null, $down ? $this->tabbedNewLine($down) : null]); $filename = $configuration->getNamingStrategy()->getFilename(); $this->writer->write($contents, $filename, $configuration->getMigrationsDirectory()); return $filename; }
public function test_can_replace_variables() { $replacer = new VariableReplacer(); $contents = $replacer->replace('<variable> <variable2>', ['<variable>', '<variable2>'], ['value', 'value2']); $this->assertEquals('value value2', $contents); }