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 |
||
30 | class User |
||
31 | { |
||
32 | /* |
||
33 | |-------------------------------------------------------------------------- |
||
34 | | User Class |
||
35 | |-------------------------------------------------------------------------- |
||
36 | | |
||
37 | | For retreiving User Information. |
||
38 | | |
||
39 | */ |
||
40 | |||
41 | protected $details; |
||
42 | protected $query; |
||
43 | protected $result; |
||
44 | protected $connect; |
||
45 | |||
46 | /** |
||
47 | * Create a new class instance. |
||
48 | * |
||
49 | * @return void |
||
|
|||
50 | */ |
||
51 | View Code Duplication | public function __construct() |
|
60 | |||
61 | /** |
||
62 | * Getting User details on the basis of uername or login Id |
||
63 | * |
||
64 | * @param string $details To store loginid/username |
||
65 | * @param boollen $para To store True/False |
||
66 | * |
||
67 | * @return array or null |
||
68 | */ |
||
69 | public function userDetails($details, $para) |
||
84 | } |
||
85 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.