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 |
||
| 9 | class RelativeNamespaceDiscoveryTest extends \Codeception\Test\Unit |
||
|
|
|||
| 10 | { |
||
| 11 | private $ds = DIRECTORY_SEPARATOR; |
||
| 12 | |||
| 13 | public function testGetClasses() |
||
| 24 | |||
| 25 | public function testGetFile() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @dataProvider testConvertPathToNamespaceData |
||
| 41 | * |
||
| 42 | * @param $path |
||
| 43 | * @param $expected |
||
| 44 | */ |
||
| 45 | View Code Duplication | public function testConvertPathToNamespace($path, $expected) |
|
| 52 | |||
| 53 | public function testConvertPathToNamespaceData() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @dataProvider testConvertNamespaceToPathData |
||
| 65 | * |
||
| 66 | * @param $namespace |
||
| 67 | * @param $expected |
||
| 68 | */ |
||
| 69 | View Code Duplication | public function testConvertNamespaceToPath($namespace, $expected) |
|
| 76 | |||
| 77 | public function testConvertNamespaceToPathData() |
||
| 85 | |||
| 86 | protected function callProtected($object, $method, $args = []) |
||
| 92 | |||
| 93 | protected function normalizePath($path) |
||
| 97 | } |
||
| 98 |
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.