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 | abstract class AbstractSmartIdQuery implements QueryInterface |
||
13 | { |
||
14 | /** @var string user personal code */ |
||
15 | private $code; |
||
16 | |||
17 | /** @var string Country related to personal code. Example EE */ |
||
18 | private $country; |
||
19 | |||
20 | /** |
||
21 | * @param string $code |
||
22 | * @param string $country |
||
23 | * @return self |
||
|
|||
24 | */ |
||
25 | 5 | public function __construct( |
|
32 | |||
33 | /** |
||
34 | * Field and values association used in query |
||
35 | * @return array |
||
36 | */ |
||
37 | 1 | public function getFields() |
|
46 | |||
47 | /** |
||
48 | * Validation constraints for request data validation |
||
49 | * @return Assert\Collection |
||
50 | */ |
||
51 | 1 | View Code Duplication | public function getValidationConstraints() |
63 | |||
64 | /** |
||
65 | * HTTP method to use |
||
66 | * @return string |
||
67 | */ |
||
68 | 1 | public function getMethod() |
|
72 | } |
||
73 |
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.