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 |
||
12 | class EnumerationFilterTypeTest extends BaseOrmFilterTest |
||
13 | { |
||
14 | /** |
||
15 | * @var \UnitTester |
||
16 | */ |
||
17 | protected $tester; |
||
18 | |||
19 | /** |
||
20 | * @var EnumerationFilterType |
||
21 | */ |
||
22 | protected $object; |
||
23 | |||
24 | protected function setUp() |
||
28 | |||
29 | View Code Duplication | public function testBindRequest() |
|
39 | |||
40 | /** |
||
41 | * @param string $comparator The comparator |
||
42 | * @param string $whereClause The where clause |
||
43 | * @param mixed $value The value |
||
44 | * @param mixed $testValue The test value |
||
45 | * |
||
46 | * @dataProvider applyDataProvider |
||
47 | */ |
||
48 | public function testApply($comparator, $whereClause, $value, $testValue) |
||
61 | |||
62 | /** |
||
63 | * @return array |
||
64 | */ |
||
65 | View Code Duplication | public static function applyDataProvider() |
|
72 | |||
73 | public function testGetTemplate() |
||
77 | } |
||
78 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.