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 |
||
| 8 | class ModelHelperTest extends TestCase |
||
| 9 | { |
||
| 10 | public function testGetModelWithoutNamespaceReturnsFalse() |
||
| 11 | { |
||
| 12 | $crudApi = new CrudApi(['namespace' => null]); |
||
| 13 | |||
| 14 | $this->assertFalse($crudApi->getModel()); |
||
|
|
|||
| 15 | } |
||
| 16 | |||
| 17 | View Code Duplication | public function testGetModelUser() |
|
| 32 | |||
| 33 | View Code Duplication | public function testUserGetModelCanBeInstantiated() |
|
| 48 | |||
| 49 | public function testAdditionalModelCanBeInstantiated() |
||
| 64 | } |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.