| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | public function execute(CapsuleInterface $capsule) |
||
| 37 | { |
||
| 38 | $schema = $capsule->getSchema($this->getTable(), $this->getDatabase()); |
||
| 39 | $database = $this->database ?? '[default]'; |
||
| 40 | |||
| 41 | if (!$schema->exists()) { |
||
| 42 | throw new TableException( |
||
| 43 | "Unable to rename table '{$database}'.'{$this->getTable()}', table does not exists" |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | if ($capsule->getDatabase($this->getDatabase())->hasTable($this->newName)) { |
||
| 48 | throw new TableException( |
||
| 49 | "Unable to rename table '{$database}'.'{$this->getTable()}', table '{$this->newName}' already exists" |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | |||
| 53 | $schema->setName($this->newName); |
||
| 54 | $schema->save(AbstractHandler::DO_ALL); |
||
| 55 | } |
||
| 56 | } |