| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 72 | 
| Code Lines | 49 | 
| 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  | 
            ||
| 50 | public function testParse()  | 
            ||
| 51 |     { | 
            ||
| 52 | $document = new Document([]);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 53 | |||
| 54 | // Only_values = false.  | 
            ||
| 55 | $content = '/NameType /FlateDecode  | 
            ||
| 56 | /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType  | 
            ||
| 57 | null/StringType(hello)/DateType(D:20130901235555+02\'00\')/XRefType 2 0 R  | 
            ||
| 58 | /NumericType 8/HexaType<0020>/BooleanType false';  | 
            ||
| 59 | $offset = 0;  | 
            ||
| 60 | |||
| 61 | $elements = Element::parse($content, $document, $offset, false);  | 
            ||
| 62 | |||
| 63 |         $this->assertTrue(\array_key_exists('NameType', $elements)); | 
            ||
| 64 | $this->assertTrue($elements['NameType'] instanceof ElementName);  | 
            ||
| 65 |         $this->assertEquals('FlateDecode', $elements['NameType']->getContent()); | 
            ||
| 66 | |||
| 67 |         $this->assertTrue(\array_key_exists('Contents', $elements)); | 
            ||
| 68 | $this->assertTrue($elements['Contents'] instanceof ElementArray);  | 
            ||
| 69 | $this->assertTrue($elements['Contents']->contains(42));  | 
            ||
| 70 | |||
| 71 |         $this->assertTrue(\array_key_exists('Fonts', $elements)); | 
            ||
| 72 | $this->assertTrue($elements['Fonts'] instanceof Header);  | 
            ||
| 73 | |||
| 74 |         $this->assertTrue(\array_key_exists('NullType', $elements)); | 
            ||
| 75 | $this->assertTrue($elements['NullType'] instanceof ElementNull);  | 
            ||
| 76 |         $this->assertEquals('null', (string) $elements['NullType']); | 
            ||
| 77 | |||
| 78 |         $this->assertTrue(\array_key_exists('StringType', $elements)); | 
            ||
| 79 | $this->assertTrue($elements['StringType'] instanceof ElementString);  | 
            ||
| 80 |         $this->assertEquals('hello', $elements['StringType']->getContent()); | 
            ||
| 81 | |||
| 82 |         $this->assertTrue(\array_key_exists('DateType', $elements)); | 
            ||
| 83 | $this->assertTrue($elements['DateType'] instanceof ElementDate);  | 
            ||
| 84 | |||
| 85 |         $this->assertTrue(\array_key_exists('XRefType', $elements)); | 
            ||
| 86 | $this->assertTrue($elements['XRefType'] instanceof ElementXRef);  | 
            ||
| 87 |         $this->assertEquals('2_0', $elements['XRefType']->getId()); | 
            ||
| 88 | |||
| 89 |         $this->assertTrue(\array_key_exists('NumericType', $elements)); | 
            ||
| 90 | $this->assertTrue($elements['NumericType'] instanceof ElementNumeric);  | 
            ||
| 91 |         $this->assertEquals('8', (string) $elements['NumericType']); | 
            ||
| 92 | |||
| 93 |         $this->assertTrue(\array_key_exists('HexaType', $elements)); | 
            ||
| 94 | $this->assertTrue($elements['HexaType'] instanceof ElementString);  | 
            ||
| 95 |         $this->assertEquals(' ', (string) $elements['HexaType']); | 
            ||
| 96 | |||
| 97 |         $this->assertTrue(\array_key_exists('BooleanType', $elements)); | 
            ||
| 98 | $this->assertTrue($elements['BooleanType'] instanceof ElementBoolean);  | 
            ||
| 99 | $this->assertFalse($elements['BooleanType']->getContent());  | 
            ||
| 100 | |||
| 101 | // Only_values = true.  | 
            ||
| 102 | $content = '/NameType /FlateDecode';  | 
            ||
| 103 | $offset = 0;  | 
            ||
| 104 | $elements = Element::parse($content, $document, $offset, true);  | 
            ||
| 105 | $this->assertEquals(2, \count($elements));  | 
            ||
| 106 | $this->assertEquals(22, $offset);  | 
            ||
| 107 | |||
| 108 | // Test error.  | 
            ||
| 109 | $content = '/NameType /FlateDecode $$$';  | 
            ||
| 110 | $offset = 0;  | 
            ||
| 111 | $elements = Element::parse($content, $document, $offset, false);  | 
            ||
| 112 | $this->assertEquals(1, \count($elements));  | 
            ||
| 113 | $this->assertEquals(22, $offset);  | 
            ||
| 114 |         $this->assertEquals('NameType', key($elements)); | 
            ||
| 115 | $this->assertTrue(current($elements) instanceof ElementName);  | 
            ||
| 116 | |||
| 117 | $content = '/NameType $$$';  | 
            ||
| 118 | $offset = 0;  | 
            ||
| 119 | $elements = Element::parse($content, $document, $offset, false);  | 
            ||
| 120 | $this->assertEquals(0, $offset);  | 
            ||
| 121 | $this->assertEquals(0, \count($elements));  | 
            ||
| 122 | }  | 
            ||
| 154 | 
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.