Conditions | 1 |
Paths | 1 |
Total Lines | 96 |
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 |
||
138 | public function testMultilevel() |
||
139 | { |
||
140 | $data = [ |
||
141 | 'ROOT' => [ |
||
142 | 'ROOT_CAPTION' => 'TEXT', |
||
143 | 'LEVEL1' => [ |
||
144 | [ |
||
145 | 'LEVEL1_CAPTION' => '1', |
||
146 | 'LEVEL2' => [ |
||
147 | [ |
||
148 | 'LEVEL2_CAPTION' => '1.1' |
||
149 | ] |
||
150 | ] |
||
151 | ], |
||
152 | [ |
||
153 | 'LEVEL1_CAPTION' => '2', |
||
154 | 'LEVEL2' => [ |
||
155 | [ |
||
156 | 'LEVEL2_CAPTION' => '2.1' |
||
157 | ] |
||
158 | ] |
||
159 | ] |
||
160 | ] |
||
161 | ] |
||
162 | ]; |
||
163 | |||
164 | $namedRanges = [ |
||
165 | 'ROOT' => Array( |
||
166 | 0 => Array( |
||
167 | 0 => 'ROOT', |
||
168 | 1 => '{{ROOT_CAPTION}}', |
||
169 | ), |
||
170 | 1 => Array( |
||
171 | 0 => 'LEVEL1', |
||
172 | 1 => '{{LEVEL1_CAPTION}}', |
||
173 | ), |
||
174 | 2 => Array( |
||
175 | 0 => 'LEVEL2-R', |
||
176 | 1 => '{{LEVEL2_CAPTION}}', |
||
177 | ), |
||
178 | 3 => Array( |
||
179 | 0 => 'ROOT_FOOTER', |
||
180 | ) |
||
181 | ), |
||
182 | 'LEVEL1' => Array( |
||
183 | 1 => Array( |
||
184 | 0 => 'LEVEL1', |
||
185 | 1 => '{{LEVEL1_CAPTION}}', |
||
186 | ), |
||
187 | 2 => Array( |
||
188 | 0 => 'LEVEL2-1', |
||
189 | 1 => '{{LEVEL2_CAPTION}}', |
||
190 | ) |
||
191 | ), |
||
192 | 'LEVEL2' => Array( |
||
193 | 2 => Array( |
||
194 | 0 => 'LEVEL2', |
||
195 | 1 => '{{LEVEL2_CAPTION}}', |
||
196 | ) |
||
197 | ) |
||
198 | ]; |
||
199 | |||
200 | $renderer = new \PHPExcelReport\Report\ReportRenderer( |
||
201 | $this->rendererRepository, |
||
202 | new \PHPExcelReport\Report\Compiler\ReportDataCompiler($this->logger), |
||
203 | $namedRanges, |
||
204 | $this->logger); |
||
205 | |||
206 | $canvas = $renderer->render($data); |
||
207 | |||
208 | $this->assertEquals([ |
||
209 | 0 => [ |
||
210 | 0 => 'ROOT', |
||
211 | 1 => 'TEXT' |
||
212 | ], |
||
213 | 1 => [ |
||
214 | 0 => 'LEVEL1', |
||
215 | 1 => '1' |
||
216 | ], |
||
217 | 2 => [ |
||
218 | 0 => 'LEVEL2', |
||
219 | 1 => '1.1' |
||
220 | ], |
||
221 | 3 => [ |
||
222 | 0 => 'LEVEL1', |
||
223 | 1 => '2' |
||
224 | ], |
||
225 | 4 => [ |
||
226 | 0 => 'LEVEL2', |
||
227 | 1 => '2.1' |
||
228 | ], |
||
229 | 5 => [ |
||
230 | 0 => 'ROOT_FOOTER' |
||
231 | ] |
||
232 | ], $canvas->getArrayCopy()); |
||
233 | } |
||
234 | |||
236 |