| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| 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 |
||
| 27 | public function testSimple() |
||
| 28 | { |
||
| 29 | $data = [ |
||
| 30 | 'HEADER' => [ |
||
| 31 | 'HEADER_CAPTION' => 'I am Header' |
||
| 32 | ], |
||
| 33 | 'ROOT' => [ |
||
| 34 | 'ROOT_CAPTION' => 'I am Root' |
||
| 35 | ], |
||
| 36 | 'FOOTER' => [ |
||
| 37 | 'FOOTER_CAPTION' => 'I am Footer' |
||
| 38 | ] |
||
| 39 | ]; |
||
| 40 | |||
| 41 | $namedRanges = [ |
||
| 42 | 'HEADER' => Array( |
||
| 43 | 0 => Array( |
||
| 44 | 0 => 'HEADER {{HEADER_CAPTION}}', |
||
| 45 | ), |
||
| 46 | ), |
||
| 47 | 'ROOT' => Array( |
||
| 48 | 1 => Array( |
||
| 49 | 0 => 'ROOT {{ROOT_CAPTION}}', |
||
| 50 | ), |
||
| 51 | ), |
||
| 52 | 'FOOTER' => Array( |
||
| 53 | 2 => Array( |
||
| 54 | 0 => 'FOOTER {{FOOTER_CAPTION}}', |
||
| 55 | ), |
||
| 56 | ), |
||
| 57 | ]; |
||
| 58 | |||
| 59 | $renderer = new \PHPExcelReport\Report\ReportRenderer( |
||
| 60 | $this->rendererRepository, |
||
| 61 | new \PHPExcelReport\Report\Compiler\ReportDataCompiler($this->logger), |
||
| 62 | $namedRanges, |
||
| 63 | $this->logger); |
||
| 64 | |||
| 65 | $canvas = $renderer->render($data); |
||
| 66 | |||
| 67 | $this->assertEquals([ |
||
| 68 | 0 => [ |
||
| 69 | 0 => 'HEADER I am Header' |
||
| 70 | ], |
||
| 71 | 1 => [ |
||
| 72 | 0 => 'ROOT I am Root' |
||
| 73 | ], |
||
| 74 | 2 => [ |
||
| 75 | 0 => 'FOOTER I am Footer' |
||
| 76 | ] |
||
| 77 | ], $canvas->getArrayCopy()); |
||
| 78 | } |
||
| 79 | |||
| 236 |