| 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  | 
            ||
| 52 | public function testParse(): void  | 
            ||
| 53 |     { | 
            ||
| 54 | $document = $this->getDocumentInstance();  | 
            ||
| 55 | |||
| 56 | // Only_values = false.  | 
            ||
| 57 | $content = '/NameType /FlateDecode  | 
            ||
| 58 | /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType  | 
            ||
| 59 | null/StringType(hello)/DateType(D:20130901235555+02\'00\')/XRefType 2 0 R  | 
            ||
| 60 | /NumericType 8/HexaType<0020>/BooleanType false';  | 
            ||
| 61 | $offset = 0;  | 
            ||
| 62 | |||
| 63 | $elements = Element::parse($content, $document, $offset, false);  | 
            ||
| 64 | |||
| 65 |         $this->assertTrue(\array_key_exists('NameType', $elements)); | 
            ||
| 66 | $this->assertTrue($elements['NameType'] instanceof ElementName);  | 
            ||
| 67 |         $this->assertEquals('FlateDecode', $elements['NameType']->getContent()); | 
            ||
| 68 | |||
| 69 |         $this->assertTrue(\array_key_exists('Contents', $elements)); | 
            ||
| 70 | $this->assertTrue($elements['Contents'] instanceof ElementArray);  | 
            ||
| 71 | $this->assertTrue($elements['Contents']->contains(42));  | 
            ||
| 72 | |||
| 73 |         $this->assertTrue(\array_key_exists('Fonts', $elements)); | 
            ||
| 74 | $this->assertTrue($elements['Fonts'] instanceof Header);  | 
            ||
| 75 | |||
| 76 |         $this->assertTrue(\array_key_exists('NullType', $elements)); | 
            ||
| 77 | $this->assertTrue($elements['NullType'] instanceof ElementNull);  | 
            ||
| 78 |         $this->assertEquals('null', (string) $elements['NullType']); | 
            ||
| 79 | |||
| 80 |         $this->assertTrue(\array_key_exists('StringType', $elements)); | 
            ||
| 81 | $this->assertTrue($elements['StringType'] instanceof ElementString);  | 
            ||
| 82 |         $this->assertEquals('hello', $elements['StringType']->getContent()); | 
            ||
| 83 | |||
| 84 |         $this->assertTrue(\array_key_exists('DateType', $elements)); | 
            ||
| 85 | $this->assertTrue($elements['DateType'] instanceof ElementDate);  | 
            ||
| 86 | |||
| 87 |         $this->assertTrue(\array_key_exists('XRefType', $elements)); | 
            ||
| 88 | $this->assertTrue($elements['XRefType'] instanceof ElementXRef);  | 
            ||
| 89 |         $this->assertEquals('2_0', $elements['XRefType']->getId()); | 
            ||
| 90 | |||
| 91 |         $this->assertTrue(\array_key_exists('NumericType', $elements)); | 
            ||
| 92 | $this->assertTrue($elements['NumericType'] instanceof ElementNumeric);  | 
            ||
| 93 |         $this->assertEquals('8', (string) $elements['NumericType']); | 
            ||
| 94 | |||
| 95 |         $this->assertTrue(\array_key_exists('HexaType', $elements)); | 
            ||
| 96 | $this->assertTrue($elements['HexaType'] instanceof ElementString);  | 
            ||
| 97 |         $this->assertEquals(' ', (string) $elements['HexaType']); | 
            ||
| 98 | |||
| 99 |         $this->assertTrue(\array_key_exists('BooleanType', $elements)); | 
            ||
| 100 | $this->assertTrue($elements['BooleanType'] instanceof ElementBoolean);  | 
            ||
| 101 | $this->assertFalse($elements['BooleanType']->getContent());  | 
            ||
| 102 | |||
| 103 | // Only_values = true.  | 
            ||
| 104 | $content = '/NameType /FlateDecode';  | 
            ||
| 105 | $offset = 0;  | 
            ||
| 106 | $elements = Element::parse($content, $document, $offset, true);  | 
            ||
| 107 | $this->assertEquals(2, \count($elements));  | 
            ||
| 108 | $this->assertEquals(22, $offset);  | 
            ||
| 109 | |||
| 110 | // Test error.  | 
            ||
| 111 | $content = '/NameType /FlateDecode $$$';  | 
            ||
| 112 | $offset = 0;  | 
            ||
| 113 | $elements = Element::parse($content, $document, $offset, false);  | 
            ||
| 114 | $this->assertEquals(1, \count($elements));  | 
            ||
| 115 | $this->assertEquals(22, $offset);  | 
            ||
| 116 |         $this->assertEquals('NameType', key($elements)); | 
            ||
| 117 | $this->assertTrue(current($elements) instanceof ElementName);  | 
            ||
| 118 | |||
| 119 | $content = '/NameType $$$';  | 
            ||
| 120 | $offset = 0;  | 
            ||
| 121 | $elements = Element::parse($content, $document, $offset, false);  | 
            ||
| 122 | $this->assertEquals(0, $offset);  | 
            ||
| 123 | $this->assertEquals(0, \count($elements));  | 
            ||
| 124 | }  | 
            ||
| 156 |