| Total Complexity | 8 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | class Alter extends EmulateBySql |
||
| 11 | { |
||
| 12 | use Utils; |
||
| 13 | /** |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $index; |
||
| 17 | |||
| 18 | public function setBody($params = null) |
||
| 19 | { |
||
| 20 | if (isset($this->index)) { |
||
| 21 | if (isset($params['operation'])) { |
||
| 22 | if ($params['operation'] === 'add' && isset($params['column'])) { |
||
| 23 | return parent::setBody(['query' => "ALTER TABLE " . $this->index . " ADD COLUMN " . |
||
| 24 | $params['column']['name'] . " " . strtoupper($params['column']['type'])]); |
||
| 25 | } |
||
| 26 | if ($params['operation'] === 'drop') { |
||
| 27 | return parent::setBody(['query' => "ALTER TABLE " . $this->index . " DROP COLUMN " . |
||
| 28 | $params['column']['name']]); |
||
| 29 | } |
||
| 30 | //@todo alter setting, once is merged in master |
||
| 31 | } |
||
| 32 | throw new RuntimeException('Operation is missing.'); |
||
| 33 | } |
||
| 34 | throw new RuntimeException('Index name is missing.'); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return mixed |
||
| 39 | */ |
||
| 40 | public function getIndex() |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param mixed $index |
||
| 47 | */ |
||
| 48 | public function setIndex($index) |
||
| 53 |