Conditions | 3 |
Paths | 1 |
Total Lines | 78 |
Code Lines | 68 |
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 |
||
189 | protected function configureMappings(): array |
||
190 | { |
||
191 | return [ |
||
192 | 'autoFilter' => function ($value) { $this->object->setAutoFilter($value); }, |
||
193 | 'columnDimension' => [ |
||
194 | '__multi' => function ($column = 'default'): ColumnDimension { |
||
195 | return $column === 'default' ? |
||
196 | $this->object->getDefaultColumnDimension() : |
||
197 | $this->object->getColumnDimension($column); |
||
198 | }, |
||
199 | 'autoSize' => function ($value, ColumnDimension $object) { $object->setAutoSize($value); }, |
||
200 | 'collapsed' => function ($value, ColumnDimension $object) { $object->setCollapsed($value); }, |
||
201 | 'columnIndex' => function ($value, ColumnDimension $object) { $object->setColumnIndex($value); }, |
||
202 | 'outlineLevel' => function ($value, ColumnDimension $object) { $object->setOutlineLevel($value); }, |
||
203 | 'visible' => function ($value, ColumnDimension $object) { $object->setVisible($value); }, |
||
204 | 'width' => function ($value, ColumnDimension $object) { $object->setWidth($value); }, |
||
205 | 'xfIndex' => function ($value, ColumnDimension $object) { $object->setXfIndex($value); }, |
||
206 | ], |
||
207 | 'pageMargins' => [ |
||
208 | 'top' => function ($value) { $this->object->getPageMargins()->setTop($value); }, |
||
209 | 'bottom' => function ($value) { $this->object->getPageMargins()->setBottom($value); }, |
||
210 | 'left' => function ($value) { $this->object->getPageMargins()->setLeft($value); }, |
||
211 | 'right' => function ($value) { $this->object->getPageMargins()->setRight($value); }, |
||
212 | 'header' => function ($value) { $this->object->getPageMargins()->setHeader($value); }, |
||
213 | 'footer' => function ($value) { $this->object->getPageMargins()->setFooter($value); }, |
||
214 | ], |
||
215 | 'pageSetup' => [ |
||
216 | 'fitToHeight' => function ($value) { $this->object->getPageSetup()->setFitToHeight($value); }, |
||
217 | 'fitToPage' => function ($value) { $this->object->getPageSetup()->setFitToPage($value); }, |
||
218 | 'fitToWidth' => function ($value) { $this->object->getPageSetup()->setFitToWidth($value); }, |
||
219 | 'horizontalCentered' => function ($value) { $this->object->getPageSetup()->setHorizontalCentered($value); }, |
||
220 | 'orientation' => function ($value) { $this->object->getPageSetup()->setOrientation($value); }, |
||
221 | 'paperSize' => function ($value) { $this->object->getPageSetup()->setPaperSize($value); }, |
||
222 | 'printArea' => function ($value) { $this->object->getPageSetup()->setPrintArea($value); }, |
||
223 | 'scale' => function ($value) { $this->object->getPageSetup()->setScale($value); }, |
||
224 | 'verticalCentered' => function ($value) { $this->object->getPageSetup()->setVerticalCentered($value); }, |
||
225 | ], |
||
226 | 'printGridlines' => function ($value) { $this->object->setPrintGridlines($value); }, |
||
227 | 'protection' => [ |
||
228 | 'autoFilter' => function ($value) { $this->object->getProtection()->setAutoFilter($value); }, |
||
229 | 'deleteColumns' => function ($value) { $this->object->getProtection()->setDeleteColumns($value); }, |
||
230 | 'deleteRows' => function ($value) { $this->object->getProtection()->setDeleteRows($value); }, |
||
231 | 'formatCells' => function ($value) { $this->object->getProtection()->setFormatCells($value); }, |
||
232 | 'formatColumns' => function ($value) { $this->object->getProtection()->setFormatColumns($value); }, |
||
233 | 'formatRows' => function ($value) { $this->object->getProtection()->setFormatRows($value); }, |
||
234 | 'insertColumns' => function ($value) { $this->object->getProtection()->setInsertColumns($value); }, |
||
235 | 'insertHyperlinks' => function ($value) { $this->object->getProtection()->setInsertHyperlinks($value); }, |
||
236 | 'insertRows' => function ($value) { $this->object->getProtection()->setInsertRows($value); }, |
||
237 | 'objects' => function ($value) { $this->object->getProtection()->setObjects($value); }, |
||
238 | 'password' => function ($value) { $this->object->getProtection()->setPassword($value); }, |
||
239 | 'pivotTables' => function ($value) { $this->object->getProtection()->setPivotTables($value); }, |
||
240 | 'scenarios' => function ($value) { $this->object->getProtection()->setScenarios($value); }, |
||
241 | 'selectLockedCells' => function ($value) { $this->object->getProtection()->setSelectLockedCells($value); }, |
||
242 | 'selectUnlockedCells' => function ($value) { $this->object->getProtection()->setSelectUnlockedCells($value); }, |
||
243 | 'sheet' => function ($value) { $this->object->getProtection()->setSheet($value); }, |
||
244 | 'sort' => function ($value) { $this->object->getProtection()->setSort($value); }, |
||
245 | ], |
||
246 | 'rightToLeft' => function ($value) { $this->object->setRightToLeft($value); }, |
||
247 | 'rowDimension' => [ |
||
248 | '__multi' => function ($column = 'default'): RowDimension { |
||
249 | return $column === 'default' ? |
||
250 | $this->object->getDefaultRowDimension() : |
||
251 | $this->object->getRowDimension($column); |
||
252 | }, |
||
253 | 'collapsed' => function ($value, RowDimension $object) { $object->setCollapsed($value); }, |
||
254 | 'outlineLevel' => function ($value, RowDimension $object) { $object->setOutlineLevel($value); }, |
||
255 | 'rowHeight' => function ($value, RowDimension $object) { $object->setRowHeight($value); }, |
||
256 | 'rowIndex' => function ($value, RowDimension $object) { $object->setRowIndex($value); }, |
||
257 | 'visible' => function ($value, RowDimension $object) { $object->setVisible($value); }, |
||
258 | 'xfIndex' => function ($value, RowDimension $object) { $object->setXfIndex($value); }, |
||
259 | 'zeroHeight' => function ($value, RowDimension $object) { $object->setZeroHeight($value); }, |
||
260 | ], |
||
261 | 'sheetState' => function ($value) { $this->object->setSheetState($value); }, |
||
262 | 'showGridlines' => function ($value) { $this->object->setShowGridlines($value); }, |
||
263 | 'tabColor' => function ($value) { $this->object->getTabColor()->setRGB($value); }, |
||
264 | 'zoomScale' => function ($value) { $this->object->getSheetView()->setZoomScale($value); }, |
||
265 | ]; |
||
266 | } |
||
267 | } |
||
268 |