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 |
||
61 | protected function initializeMappings() |
||
62 | { |
||
63 | $this->mappings['break'] = function ($value) { |
||
64 | $this->sheetWrapper->getObject()->setBreak($this->object->getCoordinate(), $value); |
||
65 | }; |
||
66 | $this->mappings['dataType'] = function ($value) { |
||
67 | $this->object->setDataType($value); |
||
68 | }; |
||
69 | $this->mappings['dataValidation']['allowBlank'] = function ($value) { |
||
70 | $this->object->getDataValidation()->setAllowBlank($value); |
||
71 | }; |
||
72 | $this->mappings['dataValidation']['error'] = function ($value) { |
||
73 | $this->object->getDataValidation()->setError($value); |
||
74 | }; |
||
75 | $this->mappings['dataValidation']['errorStyle'] = function ($value) { |
||
76 | $this->object->getDataValidation()->setErrorStyle($value); |
||
77 | }; |
||
78 | $this->mappings['dataValidation']['errorTitle'] = function ($value) { |
||
79 | $this->object->getDataValidation()->setErrorTitle($value); |
||
80 | }; |
||
81 | $this->mappings['dataValidation']['formula1'] = function ($value) { |
||
82 | $this->object->getDataValidation()->setFormula1($value); |
||
83 | }; |
||
84 | $this->mappings['dataValidation']['formula2'] = function ($value) { |
||
85 | $this->object->getDataValidation()->setFormula2($value); |
||
86 | }; |
||
87 | $this->mappings['dataValidation']['operator'] = function ($value) { |
||
88 | $this->object->getDataValidation()->setOperator($value); |
||
89 | }; |
||
90 | $this->mappings['dataValidation']['prompt'] = function ($value) { |
||
91 | $this->object->getDataValidation()->setPrompt($value); |
||
92 | }; |
||
93 | $this->mappings['dataValidation']['promptTitle'] = function ($value) { |
||
94 | $this->object->getDataValidation()->setPromptTitle($value); |
||
95 | }; |
||
96 | $this->mappings['dataValidation']['showDropDown'] = function ($value) { |
||
97 | $this->object->getDataValidation()->setShowDropDown($value); |
||
98 | }; |
||
99 | $this->mappings['dataValidation']['showErrorMessage'] = function ($value) { |
||
100 | $this->object->getDataValidation()->setShowErrorMessage($value); |
||
101 | }; |
||
102 | $this->mappings['dataValidation']['showInputMessage'] = function ($value) { |
||
103 | $this->object->getDataValidation()->setShowInputMessage($value); |
||
104 | }; |
||
105 | $this->mappings['dataValidation']['type'] = function ($value) { |
||
106 | $this->object->getDataValidation()->setType($value); |
||
107 | }; |
||
108 | $this->mappings['merge'] = function ($value) { |
||
109 | if (is_int($value)) { |
||
110 | $value = PHPExcel_Cell::stringFromColumnIndex($value) . $this->sheetWrapper->getRow(); |
||
111 | } |
||
112 | $this->sheetWrapper->getObject()->mergeCells(sprintf('%s:%s', $this->object->getCoordinate(), $value)); |
||
113 | }; |
||
114 | $this->mappings['style'] = function ($value) { |
||
115 | $this->sheetWrapper->getObject()->getStyle($this->object->getCoordinate())->applyFromArray($value); |
||
116 | }; |
||
117 | $this->mappings['url'] = function ($value) { |
||
118 | $this->object->getHyperlink()->setUrl($value); |
||
119 | }; |
||
120 | } |
||
121 | |||
222 |