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