| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Code Lines | 36 |
| 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 |
||
| 85 | public function testParseReusingStringReader() |
||
| 86 | { |
||
| 87 | $sut = $this->getSubjectUnderTest(); |
||
| 88 | |||
| 89 | /* |
||
| 90 | * first run |
||
| 91 | */ |
||
| 92 | $data = '@prefix : <http://ex/> . |
||
| 93 | :decimals :dec 1.0, 2.2, 0.1 .'; |
||
| 94 | |||
| 95 | $sut->parse('http://', $data); |
||
| 96 | |||
| 97 | $this->assertEquals( |
||
| 98 | [ |
||
| 99 | 'type' => 'triple', |
||
| 100 | 's' => 'http://ex/decimals', |
||
| 101 | 's_type' => 'uri', |
||
| 102 | 'p' => 'http://ex/dec', |
||
| 103 | 'p_type' => 'uri', |
||
| 104 | 'o' => '1.0', |
||
| 105 | 'o_type' => 'literal', |
||
| 106 | 'o_datatype' => 'http://www.w3.org/2001/XMLSchema#decimal', |
||
| 107 | 'o_lang' => '', |
||
| 108 | ], |
||
| 109 | $sut->getTriples()[0] |
||
| 110 | ); |
||
| 111 | |||
| 112 | /* |
||
| 113 | * second run |
||
| 114 | */ |
||
| 115 | $data = '@prefix : <http://ex/> . |
||
| 116 | :decimals :dec "foo", 0.42 .'; |
||
| 117 | |||
| 118 | $sut->parse('http://', $data); |
||
| 119 | |||
| 120 | $this->assertEquals( |
||
| 121 | [ |
||
| 122 | [ |
||
| 123 | 'type' => 'triple', |
||
| 124 | 's' => 'http://ex/decimals', |
||
| 125 | 's_type' => 'uri', |
||
| 126 | 'p' => 'http://ex/dec', |
||
| 127 | 'p_type' => 'uri', |
||
| 128 | 'o' => 'foo', |
||
| 129 | 'o_type' => 'literal', |
||
| 130 | 'o_datatype' => '', |
||
| 131 | 'o_lang' => '', |
||
| 132 | ], |
||
| 133 | [ |
||
| 134 | 'type' => 'triple', |
||
| 135 | 's' => 'http://ex/decimals', |
||
| 136 | 's_type' => 'uri', |
||
| 137 | 'p' => 'http://ex/dec', |
||
| 138 | 'p_type' => 'uri', |
||
| 139 | 'o' => '0.42', |
||
| 140 | 'o_type' => 'literal', |
||
| 141 | 'o_datatype' => 'http://www.w3.org/2001/XMLSchema#decimal', |
||
| 142 | 'o_lang' => '', |
||
| 143 | ], |
||
| 144 | ], |
||
| 145 | $sut->getTriples() |
||
| 146 | ); |
||
| 149 |