Файл: src/vendor/xethron/migrations-generator/src/Xethron/MigrationsGenerator/Syntax/Table.php
Строк: 43
<?php namespace XethronMigrationsGeneratorSyntax;
/**
* Class Table
* @package XethronMigrationsGeneratorSyntax
*/
abstract class Table extends WayGeneratorsSyntaxTable{
/**
* @var string
*/
protected $table;
/**
* @param array $fields
* @param string $table
* @param string $method
* @return string
*/
public function run(array $fields, $table, $method = 'table')
{
$this->table = $table;
$compiled = $this->compiler->compile($this->getTemplate(), ['table'=>$table,'method'=>$method]);
return $this->replaceFieldsWith($this->getItems($fields), $compiled);
}
/**
* Return string for adding all foreign keys
*
* @param array $items
* @return array
*/
protected function getItems(array $items)
{
$result = array();
foreach($items as $item) {
$result[] = $this->getItem($item);
}
return $result;
}
/**
* @param array $item
* @return string
*/
abstract protected function getItem(array $item);
/**
* @param $decorators
* @return string
*/
protected function addDecorators($decorators)
{
$output = '';
foreach ($decorators as $decorator) {
$output .= sprintf("->%s", $decorator);
// Do we need to tack on the parens?
if (strpos($decorator, '(') === false) {
$output .= '()';
}
}
return $output;
}
}