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 |
||
4 | class Response |
||
5 | { |
||
6 | /** @var \SimpleXMLElement */ |
||
7 | protected $xml; |
||
8 | |||
9 | 3 | public function __construct(\SimpleXMLElement $xml) |
|
13 | |||
14 | /** |
||
15 | * Was this API call successful |
||
16 | * |
||
17 | * @return bool |
||
18 | */ |
||
19 | 3 | public function isSuccess() |
|
23 | |||
24 | /** |
||
25 | * If not return error code |
||
26 | */ |
||
27 | 2 | View Code Duplication | public function getErrorCode() |
35 | |||
36 | /** |
||
37 | * If not return error message |
||
38 | */ |
||
39 | 2 | View Code Duplication | public function getErrorMessage() |
47 | |||
48 | /** |
||
49 | * Return XML response from Wiziq |
||
50 | * |
||
51 | * @return \SimpleXMLElement |
||
52 | */ |
||
53 | 2 | public function getResponse() |
|
57 | } |
||
58 |