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 |
||
| 15 | abstract class AbstractSourceTest extends \PHPUnit_Framework_TestCase |
||
| 16 | { |
||
| 17 | public function setUp() |
||
| 25 | |||
| 26 | protected static function getTestedClass() |
||
| 30 | |||
| 31 | protected static function getExpectedStrength() |
||
| 35 | |||
| 36 | View Code Duplication | public static function provideGenerate() |
|
| 46 | |||
| 47 | public function testGetStrength() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @dataProvider provideGenerate |
||
| 57 | * @group slow |
||
| 58 | */ |
||
| 59 | public function testGenerate($length, $not) |
||
| 67 | } |
||
| 68 |