Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 7 | class FigletTest extends PHPUnit_Framework_TestCase |
||
|
|
|||
| 8 | { |
||
| 9 | public function testRender_Default() |
||
| 16 | |||
| 17 | View Code Duplication | public function testRender_SlantFont() |
|
| 25 | |||
| 26 | public function testRender_StretchedAndColorized() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @expectedException InvalidArgumentException |
||
| 41 | */ |
||
| 42 | public function testRender_UndefinedFontColor() |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @expectedException InvalidArgumentException |
||
| 52 | */ |
||
| 53 | public function testRender_UndefinedBackgroundColor() |
||
| 60 | |||
| 61 | public function testRender_ChangeFontAndCachedLetters() |
||
| 72 | |||
| 73 | View Code Duplication | public function testRender_NewFontDir() |
|
| 85 | |||
| 86 | /** |
||
| 87 | * @expectedException Exception |
||
| 88 | */ |
||
| 89 | public function testRender_BandFont() |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @return string |
||
| 102 | */ |
||
| 103 | private function getDefaultBigFontText() |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @return string |
||
| 118 | */ |
||
| 119 | private function getModifiedDefaultBigFontText($fontColor, $backgroundColor) |
||
| 133 | |||
| 134 | private function getSlantFontText() |
||
| 144 | |||
| 145 | } |
||
| 146 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.