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  | 
            ||
| 29 | abstract class FileLocatorTestCase extends TestCase  | 
            ||
| 30 | { | 
            ||
| 31 | /**  | 
            ||
| 32 | * @var string  | 
            ||
| 33 | */  | 
            ||
| 34 | protected $mappingDirectory;  | 
            ||
| 35 | |||
| 36 | /**  | 
            ||
| 37 | * @param Adapter $adapter  | 
            ||
| 38 | * @param Extractor $annotationExtractor  | 
            ||
| 39 | * @param Generator $asserterGenerator  | 
            ||
| 40 | * @param Manager $assertionManager  | 
            ||
| 41 | * @param \Closure $reflectionClassFactory  | 
            ||
| 42 | * @param \Closure $phpExtensionFactory  | 
            ||
| 43 | * @param Analyzer $analyzer  | 
            ||
| 44 | */  | 
            ||
| 45 | View Code Duplication | public function __construct(  | 
            |
| 66 | |||
| 67 | /**  | 
            ||
| 68 | * @return FileLocatorInterface  | 
            ||
| 69 | */  | 
            ||
| 70 | abstract protected function createLocator();  | 
            ||
| 71 | |||
| 72 | /**  | 
            ||
| 73 | * Test findMappingFile method.  | 
            ||
| 74 | */  | 
            ||
| 75 | public function testfindMappingFile()  | 
            ||
| 84 | |||
| 85 | /**  | 
            ||
| 86 | * Test getAllClassNames method.  | 
            ||
| 87 | */  | 
            ||
| 88 | View Code Duplication | public function testGetAllClassNames()  | 
            |
| 98 | }  | 
            ||
| 99 | 
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.