| Conditions | 6 |
| Paths | 20 |
| Total Lines | 67 |
| Code Lines | 48 |
| 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 |
||
| 35 | private function getBaseOptions(string $database, string $table): array |
||
| 36 | { |
||
| 37 | // From dump.inc.php |
||
| 38 | $db_style = ['', 'USE', 'DROP+CREATE', 'CREATE']; |
||
| 39 | $table_style = ['', 'DROP+CREATE', 'CREATE']; |
||
| 40 | $data_style = ['', 'TRUNCATE+INSERT', 'INSERT']; |
||
| 41 | if ($this->driver->jush() == 'sql') { //! use insertOrUpdate() in all drivers |
||
| 42 | $data_style[] = 'INSERT+UPDATE'; |
||
| 43 | } |
||
| 44 | |||
| 45 | $row = $this->getDataRowOptions($database, $table); |
||
| 46 | $options = [ |
||
| 47 | 'output' => [ |
||
| 48 | 'label' => $this->trans->lang('Output'), |
||
| 49 | 'options' => $this->util->dumpOutput(), |
||
| 50 | 'value' => $row['output'], |
||
| 51 | ], |
||
| 52 | 'format' => [ |
||
| 53 | 'label' => $this->trans->lang('Format'), |
||
| 54 | 'options' => $this->util->dumpFormat(), |
||
| 55 | 'value' => $row['format'], |
||
| 56 | ], |
||
| 57 | 'table_style' => [ |
||
| 58 | 'label' => $this->trans->lang('Tables'), |
||
| 59 | 'options' => $table_style, |
||
| 60 | 'value' => $row['table_style'], |
||
| 61 | ], |
||
| 62 | 'auto_increment' => [ |
||
| 63 | 'label' => $this->trans->lang('Auto Increment'), |
||
| 64 | 'value' => 1, |
||
| 65 | 'checked' => $row['autoIncrement'] ?? false, |
||
| 66 | ], |
||
| 67 | 'data_style' => [ |
||
| 68 | 'label' => $this->trans->lang('Data'), |
||
| 69 | 'options' => $data_style, |
||
| 70 | 'value' => $row['data_style'], |
||
| 71 | ], |
||
| 72 | ]; |
||
| 73 | if ($this->driver->jush() !== 'sqlite') { |
||
| 74 | $options['db_style'] = [ |
||
| 75 | 'label' => $this->trans->lang('Database'), |
||
| 76 | 'options' => $db_style, |
||
| 77 | 'value' => $row['db_style'], |
||
| 78 | ]; |
||
| 79 | if ($this->driver->support('routine')) { |
||
| 80 | $options['routines'] = [ |
||
| 81 | 'label' => $this->trans->lang('Routines'), |
||
| 82 | 'value' => 1, |
||
| 83 | 'checked' => $row['routines'], |
||
| 84 | ]; |
||
| 85 | } |
||
| 86 | if ($this->driver->support('event')) { |
||
| 87 | $options['events'] = [ |
||
| 88 | 'label' => $this->trans->lang('Events'), |
||
| 89 | 'value' => 1, |
||
| 90 | 'checked' => $row['events'], |
||
| 91 | ]; |
||
| 92 | } |
||
| 93 | } |
||
| 94 | if ($this->driver->support('trigger')) { |
||
| 95 | $options['triggers'] = [ |
||
| 96 | 'label' => $this->trans->lang('Triggers'), |
||
| 97 | 'value' => 1, |
||
| 98 | 'checked' => $row['triggers'], |
||
| 99 | ]; |
||
| 100 | } |
||
| 101 | return $options; |
||
| 102 | } |
||
| 146 |