Conditions | 1 |
Paths | 1 |
Total Lines | 80 |
Code Lines | 63 |
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 |
||
144 | public function testGetPages(): void |
||
145 | { |
||
146 | $document = $this->getDocumentInstance(); |
||
147 | |||
148 | // Listing pages from type Page |
||
149 | $content = '<</Type/Page>>'; |
||
150 | $header = Header::parse($content, $document); |
||
151 | $object1 = $this->getPageInstance($document, $header); |
||
152 | $header = Header::parse($content, $document); |
||
153 | $object2 = $this->getPageInstance($document, $header); |
||
154 | $document->setObjects([1 => $object1, 2 => $object2]); |
||
155 | $pages = $document->getPages(); |
||
156 | |||
157 | $this->assertEquals(2, \count($pages)); |
||
158 | $this->assertTrue($pages[0] instanceof Page); |
||
159 | $this->assertTrue($pages[1] instanceof Page); |
||
160 | |||
161 | // Listing pages from type Pages (kids) |
||
162 | $content = '<</Type/Page>>'; |
||
163 | $header = Header::parse($content, $document); |
||
164 | $object1 = $this->getPageInstance($document, $header); |
||
165 | $header = Header::parse($content, $document); |
||
166 | $object2 = $this->getPageInstance($document, $header); |
||
167 | $header = Header::parse($content, $document); |
||
168 | $object3 = $this->getPageInstance($document, $header); |
||
169 | |||
170 | $content = '<</Type/Pages/Kids[1 0 R 2 0 R]>>'; |
||
171 | $header = Header::parse($content, $document); |
||
172 | $object4 = $this->getPagesInstance($document, $header); |
||
173 | |||
174 | $content = '<</Type/Pages/Kids[3 0 R]>>'; |
||
175 | $header = Header::parse($content, $document); |
||
176 | $object5 = $this->getPagesInstance($document, $header); |
||
177 | |||
178 | $document->setObjects([ |
||
179 | '1_0' => $object1, |
||
180 | '2_0' => $object2, |
||
181 | '3_0' => $object3, |
||
182 | '4_0' => $object4, |
||
183 | '5_0' => $object5, |
||
184 | ]); |
||
185 | $pages = $document->getPages(); |
||
186 | |||
187 | $this->assertEquals(3, \count($pages)); |
||
188 | $this->assertTrue($pages[0] instanceof Page); |
||
189 | $this->assertTrue($pages[1] instanceof Page); |
||
190 | $this->assertTrue($pages[2] instanceof Page); |
||
191 | |||
192 | // Listing pages from type Catalog |
||
193 | $content = '<</Type/Page>>'; |
||
194 | $header = Header::parse($content, $document); |
||
195 | $object1 = $this->getPageInstance($document, $header); |
||
196 | $header = Header::parse($content, $document); |
||
197 | $object2 = $this->getPageInstance($document, $header); |
||
198 | $header = Header::parse($content, $document); |
||
199 | $object3 = $this->getPageInstance($document, $header); |
||
200 | $content = '<</Type/Pages/Kids[1 0 R 2 0 R]>>'; |
||
201 | $header = Header::parse($content, $document); |
||
202 | $object4 = $this->getPagesInstance($document, $header); |
||
203 | $content = '<</Type/Pages/Kids[4 0 R 3 0 R]>>'; |
||
204 | $header = Header::parse($content, $document); |
||
205 | $object5 = $this->getPagesInstance($document, $header); |
||
206 | $content = '<</Type/Catalog/Pages 5 0 R >>'; |
||
207 | $header = Header::parse($content, $document); |
||
208 | $object6 = $this->getPagesInstance($document, $header); |
||
209 | $document->setObjects( |
||
210 | [ |
||
211 | '1_0' => $object1, |
||
212 | '2_0' => $object2, |
||
213 | '3_0' => $object3, |
||
214 | '4_0' => $object4, |
||
215 | '5_0' => $object5, |
||
216 | '6_0' => $object6, |
||
217 | ] |
||
218 | ); |
||
219 | $pages = $document->getPages(); |
||
220 | $this->assertEquals(3, \count($pages)); |
||
221 | $this->assertTrue($pages[0] instanceof Page); |
||
222 | $this->assertTrue($pages[1] instanceof Page); |
||
223 | $this->assertTrue($pages[2] instanceof Page); |
||
224 | } |
||
268 |