| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | public function execute(CapsuleInterface $capsule): void |
||
| 42 | { |
||
| 43 | $schema = $capsule->getSchema($this->getTable()); |
||
| 44 | |||
| 45 | if (!$schema->hasColumn($this->name)) { |
||
| 46 | throw new ColumnException( |
||
| 47 | "Unable to rename column '{$schema->getName()}'.'{$this->name}', column does not exists" |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | |||
| 51 | if ($schema->hasColumn($this->newName)) { |
||
| 52 | throw new ColumnException( |
||
| 53 | sprintf( |
||
| 54 | "Unable to rename column '%s'.'%s', column '%s' already exists", |
||
| 55 | $schema->getName(), |
||
| 56 | $this->name, |
||
| 57 | $this->newName |
||
| 58 | ) |
||
| 59 | ); |
||
| 60 | } |
||
| 61 | |||
| 62 | //Declaring column |
||
| 63 | $schema->renameColumn($this->name, $this->newName); |
||
| 64 | } |
||
| 66 |