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 |
||
| 12 | class DataProviderTest extends Base |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Method save SHOULD be called on the entiy repository |
||
| 16 | */ |
||
| 17 | View Code Duplication | public function testSave() |
|
| 28 | |||
| 29 | /** |
||
| 30 | * Method delete SHOULD be called on the entity repository |
||
| 31 | */ |
||
| 32 | View Code Duplication | public function testDelete() |
|
| 43 | |||
| 44 | /** |
||
| 45 | * Method find SHOULD be called on the entity repository |
||
| 46 | */ |
||
| 47 | View Code Duplication | public function testFind() |
|
| 58 | |||
| 59 | /** |
||
| 60 | * Method findBy SHOULD be called on the entity repository |
||
| 61 | */ |
||
| 62 | View Code Duplication | public function testfindBy() |
|
| 73 | } |
||
| 74 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.