Conditions | 1 |
Paths | 1 |
Total Lines | 57 |
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 |
||
80 | public function testOnelevel() |
||
81 | { |
||
82 | $data = [ |
||
83 | 'ROOT' => [ |
||
84 | 'ROOT_CAPTION' => 'TEXT', |
||
85 | 'LEVEL1' => [ |
||
86 | [ |
||
87 | 'LEVEL1_CAPTION' => 'I am Level 1' |
||
88 | ] |
||
89 | ] |
||
90 | ] |
||
91 | ]; |
||
92 | |||
93 | $namedRanges = [ |
||
94 | 'ROOT' => Array( |
||
95 | 0 => Array( |
||
96 | 0 => 'ROOT', |
||
97 | 1 => '{{ROOT_CAPTION}}', |
||
98 | ), |
||
99 | 1 => Array( |
||
100 | 0 => 'LEVEL1', |
||
101 | 1 => '{{LEVEL1_CAPTION}}', |
||
102 | ), |
||
103 | 2 => Array( |
||
104 | 0 => 'ROOT_FOOTER', |
||
105 | ) |
||
106 | ), |
||
107 | 'LEVEL1' => Array( |
||
108 | 1 => Array( |
||
109 | 0 => 'LEVEL1', |
||
110 | 1 => '{{LEVEL1_CAPTION}}', |
||
111 | ) |
||
112 | ) |
||
113 | ]; |
||
114 | |||
115 | $renderer = new \PHPExcelReport\Report\ReportRenderer( |
||
116 | $this->rendererRepository, |
||
117 | new \PHPExcelReport\Report\Compiler\ReportDataCompiler($this->logger), |
||
118 | $namedRanges, |
||
119 | $this->logger); |
||
120 | |||
121 | $canvas = $renderer->render($data); |
||
122 | |||
123 | $this->assertEquals([ |
||
124 | 0 => [ |
||
125 | 0 => 'ROOT', |
||
126 | 1 => 'TEXT' |
||
127 | ], |
||
128 | 1 => [ |
||
129 | 0 => 'LEVEL1', |
||
130 | 1 => 'I am Level 1' |
||
131 | ], |
||
132 | 2 => [ |
||
133 | 0 => 'ROOT_FOOTER' |
||
134 | ] |
||
135 | ], $canvas->getArrayCopy()); |
||
136 | } |
||
137 | |||
236 |