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 | trait ConstructorUrl |
||
| 10 | { |
||
| 11 | use VerifyValues; |
||
| 12 | /** |
||
| 13 | * Concatenation Url In Curl |
||
| 14 | * @param $newParameters string |
||
| 15 | * @return $this |
||
| 16 | */ |
||
| 17 | protected function concatenationUrlCurl($newParameters) |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Contains guid |
||
| 31 | * @param $guid |
||
| 32 | * @return $this |
||
| 33 | */ |
||
| 34 | View Code Duplication | public function guid($guid) |
|
| 46 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: