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 |
||
31 | class Validate |
||
32 | { |
||
33 | /* |
||
34 | |-------------------------------------------------------------------------- |
||
35 | | Validate Class |
||
36 | |-------------------------------------------------------------------------- |
||
37 | | |
||
38 | | For Validating User Data whether he is registered or not. |
||
39 | | |
||
40 | */ |
||
41 | |||
42 | protected $connect; |
||
43 | |||
44 | /** |
||
45 | * Create a new class instance. |
||
46 | * |
||
47 | * @return void |
||
|
|||
48 | */ |
||
49 | View Code Duplication | public function __construct() |
|
58 | |||
59 | /** |
||
60 | * Validating Email in Database. |
||
61 | * |
||
62 | * @param string $email To store email id |
||
63 | * |
||
64 | * @return integer 0|1 |
||
65 | */ |
||
66 | View Code Duplication | public function validateEmailInDb($email) |
|
77 | |||
78 | /** |
||
79 | * Validating Username in Database. |
||
80 | * |
||
81 | * @param string $username To store username |
||
82 | * |
||
83 | * @return integer 0|1 |
||
84 | */ |
||
85 | View Code Duplication | function validateUsernameInDb($username) |
|
96 | } |
||
97 |
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.