| Conditions | 2 | 
| Paths | 3 | 
| Total Lines | 87 | 
| Code Lines | 68 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 150 | public function testGetPageInstances()  | 
            ||
| 151 |     { | 
            ||
| 152 | // Missing catalog  | 
            ||
| 153 | $document = $this->getDocumentInstance();  | 
            ||
| 154 |         try { | 
            ||
| 155 | $pages = $document->getPages();  | 
            ||
| 156 | $this->assertFalse($pages);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 157 |         } catch (\Exception $e) { | 
            ||
| 158 | $this->assertTrue($e instanceof Exception);  | 
            ||
| 159 | }  | 
            ||
| 160 | |||
| 161 | // Listing pages from type Page  | 
            ||
| 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 | $document->setObjects([1 => $object1, 2 => $object2]);  | 
            ||
| 168 | $pages = $document->getPages();  | 
            ||
| 169 | |||
| 170 | $this->assertEquals(2, \count($pages));  | 
            ||
| 171 | $this->assertTrue($pages[0] instanceof Page);  | 
            ||
| 172 | $this->assertTrue($pages[1] instanceof Page);  | 
            ||
| 173 | |||
| 174 | // Listing pages from type Pages (kids)  | 
            ||
| 175 | $content = '<</Type/Page>>';  | 
            ||
| 176 | $header = Header::parse($content, $document);  | 
            ||
| 177 | $object1 = $this->getPageInstance($document, $header);  | 
            ||
| 178 | $header = Header::parse($content, $document);  | 
            ||
| 179 | $object2 = $this->getPageInstance($document, $header);  | 
            ||
| 180 | $header = Header::parse($content, $document);  | 
            ||
| 181 | $object3 = $this->getPageInstance($document, $header);  | 
            ||
| 182 | |||
| 183 | $content = '<</Type/Pages/Kids[1 0 R 2 0 R]>>';  | 
            ||
| 184 | $header = Header::parse($content, $document);  | 
            ||
| 185 | $object4 = $this->getPagesInstance($document, $header);  | 
            ||
| 186 | |||
| 187 | $content = '<</Type/Pages/Kids[3 0 R]>>';  | 
            ||
| 188 | $header = Header::parse($content, $document);  | 
            ||
| 189 | $object5 = $this->getPagesInstance($document, $header);  | 
            ||
| 190 | |||
| 191 | $document->setObjects([  | 
            ||
| 192 | '1_0' => $object1,  | 
            ||
| 193 | '2_0' => $object2,  | 
            ||
| 194 | '3_0' => $object3,  | 
            ||
| 195 | '4_0' => $object4,  | 
            ||
| 196 | '5_0' => $object5,  | 
            ||
| 197 | ]);  | 
            ||
| 198 | $pages = $document->getPages();  | 
            ||
| 199 | |||
| 200 | $this->assertEquals(3, \count($pages));  | 
            ||
| 201 | $this->assertTrue($pages[0] instanceof Page);  | 
            ||
| 202 | $this->assertTrue($pages[1] instanceof Page);  | 
            ||
| 203 | $this->assertTrue($pages[2] instanceof Page);  | 
            ||
| 204 | |||
| 205 | // Listing pages from type Catalog  | 
            ||
| 206 | $content = '<</Type/Page>>';  | 
            ||
| 207 | $header = Header::parse($content, $document);  | 
            ||
| 208 | $object1 = $this->getPageInstance($document, $header);  | 
            ||
| 209 | $header = Header::parse($content, $document);  | 
            ||
| 210 | $object2 = $this->getPageInstance($document, $header);  | 
            ||
| 211 | $header = Header::parse($content, $document);  | 
            ||
| 212 | $object3 = $this->getPageInstance($document, $header);  | 
            ||
| 213 | $content = '<</Type/Pages/Kids[1 0 R 2 0 R]>>';  | 
            ||
| 214 | $header = Header::parse($content, $document);  | 
            ||
| 215 | $object4 = $this->getPagesInstance($document, $header);  | 
            ||
| 216 | $content = '<</Type/Pages/Kids[4 0 R 3 0 R]>>';  | 
            ||
| 217 | $header = Header::parse($content, $document);  | 
            ||
| 218 | $object5 = $this->getPagesInstance($document, $header);  | 
            ||
| 219 | $content = '<</Type/Catalog/Pages 5 0 R >>';  | 
            ||
| 220 | $header = Header::parse($content, $document);  | 
            ||
| 221 | $object6 = $this->getPagesInstance($document, $header);  | 
            ||
| 222 | $document->setObjects(  | 
            ||
| 223 | [  | 
            ||
| 224 | '1_0' => $object1,  | 
            ||
| 225 | '2_0' => $object2,  | 
            ||
| 226 | '3_0' => $object3,  | 
            ||
| 227 | '4_0' => $object4,  | 
            ||
| 228 | '5_0' => $object5,  | 
            ||
| 229 | '6_0' => $object6,  | 
            ||
| 230 | ]  | 
            ||
| 231 | );  | 
            ||
| 232 | $pages = $document->getPages();  | 
            ||
| 233 | $this->assertEquals(3, \count($pages));  | 
            ||
| 234 | $this->assertTrue($pages[0] instanceof Page);  | 
            ||
| 235 | $this->assertTrue($pages[1] instanceof Page);  | 
            ||
| 236 | $this->assertTrue($pages[2] instanceof Page);  | 
            ||
| 237 | }  | 
            ||
| 239 |