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 |
||
18 | class DecryptResponse extends Response |
||
19 | { |
||
20 | protected $parametersName = array( |
||
21 | // Mandatory |
||
22 | 'TransactionType', |
||
23 | 'TransactionResult', |
||
24 | 'ShopTransactionID', |
||
25 | 'BankTransactionID', |
||
26 | 'AuthorizationCode', |
||
27 | 'Currency', |
||
28 | 'Amount', |
||
29 | 'ErrorCode', |
||
30 | 'ErrorDescription', |
||
31 | |||
32 | // Optional |
||
33 | 'Country', |
||
34 | 'CustomInfo', |
||
35 | 'Buyer', // contains BuyerName and BuyerEmail |
||
36 | 'TDLevel', |
||
37 | 'AlertCode', |
||
38 | 'AlertDescription', |
||
39 | 'CVVPresent', |
||
40 | 'MaskedPAN', |
||
41 | 'PaymentMethod', |
||
42 | 'TOKEN', |
||
43 | 'ProductType', |
||
44 | 'TokenExpiryMonth', |
||
45 | 'TokenExpiryYear', |
||
46 | 'TransactionKey', |
||
47 | 'VbV', |
||
48 | 'VbVRisp', |
||
49 | 'VbVBuyer', |
||
50 | 'VbVFlag', |
||
51 | ); |
||
52 | protected $separator = '*P1*'; |
||
53 | |||
54 | /** |
||
55 | * @param \stdClass $soapResponse |
||
56 | * @throws \Exception |
||
57 | */ |
||
58 | 15 | public function __construct($soapResponse) |
|
66 | |||
67 | /** |
||
68 | * @return array |
||
69 | */ |
||
70 | 1 | View Code Duplication | public function getCustomInfoToArray() |
81 | } |
||
82 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.