public function toDSL(Grammar $grammar)
{
$statements = [];
// Each type of command has a corresponding compiler function on the schema
// grammar which is used to build the necessary DSL statements to build
// the blueprint element, so we'll just call that compilers function.
foreach ($this->commands as $command) {
$method = 'compile' . ucfirst($command->name);
if (method_exists($grammar, $method)) {
if (!is_null($dsl = $grammar->{$method}($this, $command))) {
$statements = array_merge($statements, (array) $dsl);
}
}
}
return $statements;
}