| Conditions | 5 |
| Paths | 7 |
| Total Lines | 51 |
| Code Lines | 31 |
| 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 |
||
| 92 | protected function resolve() |
||
| 93 | { |
||
| 94 | $data = $this->generateJsonData(); |
||
| 95 | |||
| 96 | // On force les valeurs par d�faut. |
||
| 97 | $resolverTable = new OptionsResolver(); |
||
| 98 | $resolverTable->setRequired(['columns']); |
||
| 99 | $resolverTable->setDefaults( |
||
| 100 | [ |
||
| 101 | 'columns' => [], |
||
| 102 | 'indexes' => [], |
||
| 103 | 'primary' => null, |
||
| 104 | 'uniques' => [], |
||
| 105 | 'collate' => null, |
||
| 106 | ] |
||
| 107 | ); |
||
| 108 | |||
| 109 | $resolverColumns = new OptionsResolver(); |
||
| 110 | $resolverColumns->setRequired(['type']); |
||
| 111 | $resolverColumns->setDefaults( |
||
| 112 | [ |
||
| 113 | 'length' => null, |
||
| 114 | 'nullable' => false, |
||
| 115 | 'defaultValue' => null, |
||
| 116 | 'extra' => null, |
||
| 117 | 'collate' => null, |
||
| 118 | ] |
||
| 119 | ); |
||
| 120 | |||
| 121 | $resolverIndex = new OptionsResolver(); |
||
| 122 | $resolverIndex->setDefaults( |
||
| 123 | [ |
||
| 124 | 'name' => '', |
||
| 125 | 'columns' => [], |
||
| 126 | ] |
||
| 127 | ); |
||
| 128 | $export = []; |
||
| 129 | foreach ($data as $nomTable => $table) { |
||
| 130 | $dataTable = $resolverTable->resolve($table); |
||
| 131 | foreach ((array)$dataTable['columns'] as $columnName => $column) { |
||
| 132 | $dataTable['columns'][$columnName] = $resolverColumns->resolve($column); |
||
| 133 | } |
||
| 134 | foreach (['indexes', 'uniques'] as $indexKey) { |
||
| 135 | foreach ((array)$dataTable[$indexKey] as $keyIndex => $index) { |
||
| 136 | $dataTable[$indexKey][$keyIndex] = $resolverIndex->resolve($index); |
||
| 137 | } |
||
| 138 | } |
||
| 139 | $export[$nomTable] = $dataTable; |
||
| 140 | } |
||
| 141 | |||
| 142 | return $export; |
||
| 143 | } |
||
| 156 |
This check marks files that end in a newline character, i.e. an empy line.