Conditions | 2 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 39 |
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 |
||
151 | protected function initializeMappings() |
||
152 | { |
||
153 | $this->mappings['break'] = function ($value) { |
||
154 | $this->sheetWrapper->getObject()->setBreak($this->object->getCoordinate(), $value); |
||
155 | }; |
||
156 | $this->mappings['dataType'] = function ($value) { |
||
157 | $this->object->setDataType($value); |
||
158 | }; |
||
159 | $this->mappings['dataValidation']['allowBlank'] = function ($value) { |
||
160 | $this->object->getDataValidation()->setAllowBlank($value); |
||
161 | }; |
||
162 | $this->mappings['dataValidation']['error'] = function ($value) { |
||
163 | $this->object->getDataValidation()->setError($value); |
||
164 | }; |
||
165 | $this->mappings['dataValidation']['errorStyle'] = function ($value) { |
||
166 | $this->object->getDataValidation()->setErrorStyle($value); |
||
167 | }; |
||
168 | $this->mappings['dataValidation']['errorTitle'] = function ($value) { |
||
169 | $this->object->getDataValidation()->setErrorTitle($value); |
||
170 | }; |
||
171 | $this->mappings['dataValidation']['formula1'] = function ($value) { |
||
172 | $this->object->getDataValidation()->setFormula1($value); |
||
173 | }; |
||
174 | $this->mappings['dataValidation']['formula2'] = function ($value) { |
||
175 | $this->object->getDataValidation()->setFormula2($value); |
||
176 | }; |
||
177 | $this->mappings['dataValidation']['operator'] = function ($value) { |
||
178 | $this->object->getDataValidation()->setOperator($value); |
||
179 | }; |
||
180 | $this->mappings['dataValidation']['prompt'] = function ($value) { |
||
181 | $this->object->getDataValidation()->setPrompt($value); |
||
182 | }; |
||
183 | $this->mappings['dataValidation']['promptTitle'] = function ($value) { |
||
184 | $this->object->getDataValidation()->setPromptTitle($value); |
||
185 | }; |
||
186 | $this->mappings['dataValidation']['showDropDown'] = function ($value) { |
||
187 | $this->object->getDataValidation()->setShowDropDown($value); |
||
188 | }; |
||
189 | $this->mappings['dataValidation']['showErrorMessage'] = function ($value) { |
||
190 | $this->object->getDataValidation()->setShowErrorMessage($value); |
||
191 | }; |
||
192 | $this->mappings['dataValidation']['showInputMessage'] = function ($value) { |
||
193 | $this->object->getDataValidation()->setShowInputMessage($value); |
||
194 | }; |
||
195 | $this->mappings['dataValidation']['type'] = function ($value) { |
||
196 | $this->object->getDataValidation()->setType($value); |
||
197 | }; |
||
198 | $this->mappings['merge'] = function ($value) { |
||
199 | if (is_int($value)) { |
||
200 | $value = Cell::stringFromColumnIndex($value).$this->sheetWrapper->getRow(); |
||
201 | } |
||
202 | $this->sheetWrapper->getObject()->mergeCells(sprintf('%s:%s', $this->object->getCoordinate(), $value)); |
||
203 | }; |
||
204 | $this->mappings['style'] = function ($value) { |
||
205 | $this->sheetWrapper->getObject()->getStyle($this->object->getCoordinate())->applyFromArray($value); |
||
206 | }; |
||
207 | $this->mappings['url'] = function ($value) { |
||
208 | $this->object->getHyperlink()->setUrl($value); |
||
209 | }; |
||
210 | } |
||
211 | } |
||
212 |