| Conditions | 5 |
| Paths | 16 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Xethron\MigrationsGenerator\Syntax; |
||
| 15 | protected function getItem(array $foreignKey): string |
||
| 16 | { |
||
| 17 | $value = $foreignKey['field']; |
||
| 18 | if (!empty($foreignKey['name'])) { |
||
| 19 | $value .= "', '".$foreignKey['name']; |
||
| 20 | } |
||
| 21 | $output = sprintf( |
||
| 22 | "\$table->foreign('%s')->references('%s')->on('%s')", |
||
| 23 | $value, |
||
| 24 | $foreignKey['references'], |
||
| 25 | $foreignKey['on'] |
||
| 26 | ); |
||
| 27 | if ($foreignKey['onUpdate']) { |
||
| 28 | $output .= sprintf("->onUpdate('%s')", $foreignKey['onUpdate']); |
||
| 29 | } |
||
| 30 | if ($foreignKey['onDelete']) { |
||
| 31 | $output .= sprintf("->onDelete('%s')", $foreignKey['onDelete']); |
||
| 32 | } |
||
| 33 | if (isset($foreignKey['decorators'])) { |
||
| 34 | $output .= $this->addDecorators($foreignKey['decorators']); |
||
| 35 | } |
||
| 36 | return $output.';'; |
||
| 37 | } |
||
| 39 |