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 |
||
6 | class FieldTest extends TestCase |
||
|
|||
7 | { |
||
8 | |||
9 | /** |
||
10 | * @expectedException Radowoj\Yaah\Exception |
||
11 | * @expectedExceptionMessage fid must be an integer |
||
12 | */ |
||
13 | public function testNonIntegerFid() |
||
17 | |||
18 | |||
19 | /** |
||
20 | * Tests that output of Field->toArray() has the exact keys expected by WebAPI |
||
21 | * @return void |
||
22 | */ |
||
23 | public function testReturnedArray() |
||
50 | |||
51 | /** |
||
52 | * Tests integer value representation |
||
53 | * @return void |
||
54 | */ |
||
55 | View Code Duplication | public function testIntegerValue() |
|
62 | |||
63 | |||
64 | /** |
||
65 | * Tests float value representation |
||
66 | * @return void |
||
67 | */ |
||
68 | View Code Duplication | public function testFloatValue() |
|
75 | |||
76 | |||
77 | public function testDateValue() |
||
85 | } |
||
86 |
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.