| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 57 | 
| Code Lines | 40 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 6 | ||
| Bugs | 1 | Features | 1 | 
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 | ||
| 84 | public function testSettingProperties() | ||
| 85 |     { | ||
| 86 | $definition = new CsvFormat(); | ||
| 87 | |||
| 88 |         static::assertSame($definition, $definition->setDelimiter("\t"), "SetDelimiter should be fluent"); | ||
| 89 |         static::assertEquals("\t", $definition->getDelimiter(), "Delimiter should be set to '\\t' (tab)"); | ||
| 90 | |||
| 91 |         static::assertSame($definition, $definition->setQuoteCharacter(''), "setQuoteCharacter should be fluent"); | ||
| 92 |         static::assertEquals('', $definition->getQuoteCharacter(), "Quote character should be blank"); | ||
| 93 | static::assertFalse($definition->hasQuotes(), "Quoting should be off"); | ||
| 94 | |||
| 95 |         static::assertSame($definition, $definition->setNullOutput(''), "setNullOutput should be fluent"); | ||
| 96 |         static::assertEquals('', $definition->getNullOutput(), "Null character should be '' (blank)'"); | ||
| 97 | |||
| 98 | static::assertSame($definition, $definition->setHeaderRow(1), "setHeaders should be fluent"); | ||
| 99 | static::assertTrue($definition->hasHeaderRow(), "Headers should be on"); | ||
| 100 | static::assertEquals(1, $definition->getHeaderRow(), "Headers should be set to 1"); | ||
| 101 | |||
| 102 | static::assertSame($definition, $definition->setDataStart(2), "setDataStart should be fluent"); | ||
| 103 | static::assertEquals(2, $definition->getDataStart(), "Data Start should be 2"); | ||
| 104 | |||
| 105 |         static::assertSame($definition, $definition->setLineTerminator('----'), "setLineTerminator should be fluent"); | ||
| 106 |         static::assertEquals("----", $definition->getLineTerminator(), "Line terminator should be '----'"); | ||
| 107 | |||
| 108 |         static::assertSame($definition, $definition->setEscapeCharacter('"'), "Set escape character should be fluent"); | ||
| 109 |         static::assertEquals('"', $definition->getEscapeCharacter(), "Escape character should be modified"); | ||
| 110 | static::assertTrue($definition->hasEscapeCharacter(), "Format should have an escape character"); | ||
| 111 | |||
| 112 |         static::assertSame($definition, $definition->setEscapeCharacter(''), "Set escape character should be fluent"); | ||
| 113 |         static::assertEquals('', $definition->getEscapeCharacter(), "Escape character should be modified"); | ||
| 114 | static::assertFalse($definition->hasEscapeCharacter(), "Format should not have an escape character"); | ||
| 115 | |||
| 116 | static::assertSame($definition, $definition->setLimit(3), "setLimit should be fluent"); | ||
| 117 | static::assertEquals(3, $definition->getLimit(), "Limit should be modified"); | ||
| 118 | |||
| 119 | static::assertSame($definition, $definition->setDoubleQuote(true), 'setDoubleQuote should be fluent'); | ||
| 120 | static::assertTrue($definition->isDoubleQuote(), 'isDoubleQuote should be true'); | ||
| 121 | |||
| 122 | static::assertSame($definition, $definition->setBom(Bom::BOM_UTF32_BE), 'setBom should be fluent'); | ||
| 123 | static::assertEquals(Bom::BOM_UTF32_BE, $definition->getBom(), 'Bom should be set to the UTF32BE BOM'); | ||
| 124 | static::assertEquals( | ||
| 125 | 'UTF-32BE', | ||
| 126 | $definition->getEncoding(), | ||
| 127 | 'getEncoding should be modified after setting the BOM' | ||
| 128 | ); | ||
| 129 | // reset | ||
| 130 | $definition->setBom(null); | ||
| 131 | static::assertEquals(null, $definition->getBom(), 'Bom should be reset to null'); | ||
| 132 | |||
| 133 | static::assertEquals( | ||
| 134 | 'UTF-8', | ||
| 135 | $definition->getEncoding(), | ||
| 136 | 'The encoding should be reset when no BOM is present' | ||
| 137 | ); | ||
| 138 |         static::assertSame($definition, $definition->setEncoding('UTF-16'), 'setEncoding should be fluent'); | ||
| 139 |         static::assertEquals('UTF-16', $definition->getEncoding(), 'The encoding should be set to UTF-16'); | ||
| 140 | } | ||
| 141 | |||
| 174 |