| Conditions | 12 |
| Paths | 56 |
| Total Lines | 31 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 19 | private function getQueries(TableEntity $tableAttrs) |
||
| 20 | { |
||
| 21 | $queries = []; |
||
| 22 | |||
| 23 | foreach ($tableAttrs->edited as $field) { |
||
| 24 | $column = $this->driver->escapeId($field[0]); |
||
| 25 | $val = $field[1]; |
||
| 26 | $val5 = $val[5] ?? ''; |
||
| 27 | if ($val[0] !== '' && $column != $val[0]) { |
||
| 28 | $queries[] = 'ALTER TABLE ' . $this->driver->table($tableAttrs->name) . " RENAME $column TO $val[0]"; |
||
| 29 | } |
||
| 30 | if ($column !== '' || $val5 !== '') { |
||
| 31 | $queries[] = 'COMMENT ON COLUMN ' . $this->driver->table($tableAttrs->name) . |
||
| 32 | ".$val[0] IS " . ($val5 != '' ? substr($val5, 9) : "''"); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | foreach ($tableAttrs->fields as $field) { |
||
| 36 | $column = $this->driver->escapeId($field[0]); |
||
| 37 | $val = $field[1]; |
||
| 38 | $val5 = $val[5] ?? ''; |
||
| 39 | if ($column !== '' || $val5 !== '') { |
||
| 40 | $queries[] = 'COMMENT ON COLUMN ' . $this->driver->table($tableAttrs->name) . |
||
| 41 | ".$val[0] IS " . ($val5 != '' ? substr($val5, 9) : "''"); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | if ($tableAttrs->comment != '') { |
||
| 45 | $queries[] = 'COMMENT ON TABLE ' . $this->driver->table($tableAttrs->name) . |
||
| 46 | ' IS ' . $this->driver->quote($tableAttrs->comment); |
||
| 47 | } |
||
| 48 | |||
| 49 | return $queries; |
||
| 50 | } |
||
| 151 |