| Conditions | 6 |
| Paths | 18 |
| Total Lines | 69 |
| Code Lines | 49 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 63 | private function getBaseOptions(string $database, string $table): array |
||
| 64 | { |
||
| 65 | // From dump.inc.php |
||
| 66 | $row = $this->getDataRowOptions($database, $table); |
||
| 67 | $options = [ |
||
| 68 | 'output' => [ |
||
| 69 | 'label' => $this->utils->trans->lang('Output'), |
||
| 70 | 'options' => $this->getSelectOutputValues(), |
||
| 71 | 'value' => $row['output'], |
||
| 72 | ], |
||
| 73 | 'format' => [ |
||
| 74 | 'label' => $this->utils->trans->lang('Format'), |
||
| 75 | 'options' => $this->getSelectFormatValues(), |
||
| 76 | 'value' => $row['format'], |
||
| 77 | ], |
||
| 78 | 'table_style' => [ |
||
| 79 | 'label' => $this->utils->trans->lang('Table'), |
||
| 80 | 'options' => $this->getSelectTableValues(), |
||
| 81 | 'value' => $row['table_style'], |
||
| 82 | ], |
||
| 83 | 'auto_increment' => [ |
||
| 84 | 'label' => $this->utils->trans->lang('Auto Increment'), |
||
| 85 | 'value' => 1, |
||
| 86 | 'checked' => $row['autoIncrement'] ?? true, |
||
| 87 | ], |
||
| 88 | 'data_style' => [ |
||
| 89 | 'label' => $this->utils->trans->lang('Data'), |
||
| 90 | 'options' => $this->getSelectDataValues(), |
||
| 91 | 'value' => $row['data_style'], |
||
| 92 | ], |
||
| 93 | ]; |
||
| 94 | if ($this->driver->support('trigger')) { |
||
| 95 | $options['triggers'] = [ |
||
| 96 | 'label' => $this->utils->trans->lang('Triggers'), |
||
| 97 | 'value' => 1, |
||
| 98 | 'checked' => $row['triggers'], |
||
| 99 | ]; |
||
| 100 | } |
||
| 101 | if ($this->driver->jush() === 'sqlite') { |
||
| 102 | return $options; |
||
| 103 | } |
||
| 104 | |||
| 105 | $options['db_style'] = [ |
||
| 106 | 'label' => $this->utils->trans->lang('Database'), |
||
| 107 | 'options' => $this->getSelectDatabaseValues(), |
||
| 108 | 'value' => $row['db_style'], |
||
| 109 | ]; |
||
| 110 | if ($this->driver->support('type')) { |
||
| 111 | $options['types'] = [ |
||
| 112 | 'label' => $this->utils->trans->lang('Types'), |
||
| 113 | 'value' => 1, |
||
| 114 | 'checked' => $row['types'], |
||
| 115 | ]; |
||
| 116 | } |
||
| 117 | if ($this->driver->support('routine')) { |
||
| 118 | $options['routines'] = [ |
||
| 119 | 'label' => $this->utils->trans->lang('Routines'), |
||
| 120 | 'value' => 1, |
||
| 121 | 'checked' => $row['routines'], |
||
| 122 | ]; |
||
| 123 | } |
||
| 124 | if ($this->driver->support('event')) { |
||
| 125 | $options['events'] = [ |
||
| 126 | 'label' => $this->utils->trans->lang('Events'), |
||
| 127 | 'value' => 1, |
||
| 128 | 'checked' => $row['events'], |
||
| 129 | ]; |
||
| 130 | } |
||
| 131 | return $options; |
||
| 132 | } |
||
| 176 |