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 |
||
9 | View Code Duplication | final class ChoosePaymentMethod |
|
10 | { |
||
11 | /** |
||
12 | * @var mixed |
||
13 | */ |
||
14 | private $paymentIdentifier; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $paymentMethod; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $orderToken; |
||
25 | |||
26 | /** |
||
27 | * @param string $orderToken |
||
28 | * @param mixed $paymentIdentifier |
||
29 | * @param string $paymentMethod |
||
30 | */ |
||
31 | public function __construct($orderToken, $paymentIdentifier, $paymentMethod) |
||
39 | |||
40 | /** |
||
41 | * @return string |
||
42 | */ |
||
43 | public function orderToken() |
||
47 | |||
48 | /** |
||
49 | * @return mixed |
||
50 | */ |
||
51 | public function paymentIdentifier() |
||
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | public function paymentMethod() |
||
63 | } |
||
64 |