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 | class FileSenderTest extends \PHPUnit_Framework_TestCase  | 
            ||
| 16 | { | 
            ||
| 17 | /**  | 
            ||
| 18 | * checks if FileSender does nothing if nothing is needed  | 
            ||
| 19 | *  | 
            ||
| 20 | * @dataProvider requestTypeProvider  | 
            ||
| 21 | * @covers Graviton\ImportExport\Service\FileSender  | 
            ||
| 22 | *  | 
            ||
| 23 | * @param string $type type of request to test  | 
            ||
| 24 | * @return void  | 
            ||
| 25 | */  | 
            ||
| 26 | View Code Duplication | public function testSenderDoesPlainRequestWithoutUploadField($type)  | 
            |
| 46 | |||
| 47 | /**  | 
            ||
| 48 | * checks if FileSender does nothing if it gets a falsy file path  | 
            ||
| 49 | *  | 
            ||
| 50 | * This test was added post-implementation, be sure to check if it is really what  | 
            ||
| 51 | * you need if you read this.  | 
            ||
| 52 | *  | 
            ||
| 53 | * @dataProvider requestTypeProvider  | 
            ||
| 54 | * @covers Graviton\ImportExport\Service\FileSender  | 
            ||
| 55 | *  | 
            ||
| 56 | * @param string $type type of request to test  | 
            ||
| 57 | * @return void  | 
            ||
| 58 | */  | 
            ||
| 59 | View Code Duplication | public function testSenderDoesPlainRequestWithFalsyUploadField($type)  | 
            |
| 82 | |||
| 83 | /**  | 
            ||
| 84 | * test if FileSender excepts to being called without json in upload cases  | 
            ||
| 85 | *  | 
            ||
| 86 | * @dataProvider requestTypeProvider  | 
            ||
| 87 | * @covers Graviton\ImportExport\Service\FileSender  | 
            ||
| 88 | *  | 
            ||
| 89 | * @return void  | 
            ||
| 90 | */  | 
            ||
| 91 | public function testExceptsToBeingCalledWithoutJsonDataInUploadCase($type)  | 
            ||
| 110 | |||
| 111 | |||
| 112 | /**  | 
            ||
| 113 | * checks if FileSender mangles the options before passing them to the client  | 
            ||
| 114 | *  | 
            ||
| 115 | * @dataProvider requestTypeProvider  | 
            ||
| 116 | * @covers Graviton\ImportExport\Service\FileSender  | 
            ||
| 117 | *  | 
            ||
| 118 | * @param string $type type of request to test  | 
            ||
| 119 | * @return void  | 
            ||
| 120 | */  | 
            ||
| 121 | public function testSenderManglesOptionsIfUploadHasBeenPassed($type)  | 
            ||
| 150 | |||
| 151 | /**  | 
            ||
| 152 | * @return array  | 
            ||
| 153 | */  | 
            ||
| 154 | public function requestTypeProvider()  | 
            ||
| 161 | }  | 
            ||
| 162 | 
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.