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 Compose |
||
31 | { |
||
32 | /* |
||
33 | |-------------------------------------------------------------------------- |
||
34 | | Compose Class |
||
35 | |-------------------------------------------------------------------------- |
||
36 | | |
||
37 | | To Compose New Message. |
||
38 | | |
||
39 | */ |
||
40 | |||
41 | protected $connect; |
||
42 | protected $array; |
||
43 | |||
44 | /** |
||
45 | * Create a new class instance. |
||
46 | * |
||
47 | * @return void |
||
|
|||
48 | */ |
||
49 | View Code Duplication | public function __construct() |
|
60 | |||
61 | /** |
||
62 | * Fetch User from the DB |
||
63 | * |
||
64 | * @param object $msg To store user id and suggestion value |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function selectUser($msg) |
||
93 | } |
||
94 | |||
95 |
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.