| Conditions | 5 |
| Paths | 12 |
| Total Lines | 35 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Xethron\MigrationsGenerator\Syntax; |
||
| 15 | protected function getItem(array $field) |
||
| 16 | { |
||
| 17 | $property = $field['field']; |
||
| 18 | |||
| 19 | // If the field is an array, |
||
| 20 | // make it an array in the Migration |
||
| 21 | if (is_array($property)) { |
||
| 22 | $property = "['". implode("','", $property) ."']"; |
||
| 23 | } else { |
||
| 24 | $property = $property ? "'$property'" : null; |
||
| 25 | } |
||
| 26 | |||
| 27 | $type = $field['type']; |
||
| 28 | |||
| 29 | $output = sprintf( |
||
| 30 | "\$table->%s(%s)", |
||
| 31 | $type, |
||
| 32 | $property |
||
| 33 | ); |
||
| 34 | |||
| 35 | // If we have args, then it needs |
||
| 36 | // to be formatted a bit differently |
||
| 37 | if (isset($field['args'])) { |
||
| 38 | $output = sprintf( |
||
| 39 | "\$table->%s(%s, %s)", |
||
| 40 | $type, |
||
| 41 | $property, |
||
| 42 | $field['args'] |
||
| 43 | ); |
||
| 44 | } |
||
| 45 | if (isset($field['decorators'])) { |
||
| 46 | $output .= $this->addDecorators( $field['decorators'] ); |
||
| 47 | } |
||
| 48 | return $output . ';'; |
||
| 49 | } |
||
| 50 | } |
||
| 51 |