| Conditions | 10 |
| Paths | 512 |
| Total Lines | 43 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 93 | protected function _initialize($attributes) |
||
| 94 | { |
||
| 95 | $this->_attributes = $attributes; |
||
| 96 | |||
| 97 | if (isset($attributes['subject']['apiErrorResponse'])) { |
||
| 98 | $wrapperNode = $attributes['subject']['apiErrorResponse']; |
||
| 99 | } else { |
||
| 100 | $wrapperNode = $attributes['subject']; |
||
| 101 | } |
||
| 102 | |||
| 103 | if (isset($wrapperNode['subscription'])) { |
||
| 104 | $this->_set('subscription', Subscription::factory($attributes['subject']['subscription'])); |
||
| 105 | } |
||
| 106 | |||
| 107 | if (isset($wrapperNode['merchantAccount'])) { |
||
| 108 | $this->_set('merchantAccount', MerchantAccount::factory($wrapperNode['merchantAccount'])); |
||
| 109 | } |
||
| 110 | |||
| 111 | if (isset($wrapperNode['transaction'])) { |
||
| 112 | $this->_set('transaction', Transaction::factory($wrapperNode['transaction'])); |
||
| 113 | } |
||
| 114 | |||
| 115 | if (isset($wrapperNode['disbursement'])) { |
||
| 116 | $this->_set('disbursement', Disbursement::factory($wrapperNode['disbursement'])); |
||
| 117 | } |
||
| 118 | |||
| 119 | if (isset($wrapperNode['partnerMerchant'])) { |
||
| 120 | $this->_set('partnerMerchant', PartnerMerchant::factory($wrapperNode['partnerMerchant'])); |
||
| 121 | } |
||
| 122 | |||
| 123 | if (isset($wrapperNode['dispute'])) { |
||
| 124 | $this->_set('dispute', Dispute::factory($wrapperNode['dispute'])); |
||
| 125 | } |
||
| 126 | |||
| 127 | if (isset($wrapperNode['accountUpdaterDailyReport'])) { |
||
| 128 | $this->_set('accountUpdaterDailyReport', AccountUpdaterDailyReport::factory($wrapperNode['accountUpdaterDailyReport'])); |
||
| 129 | } |
||
| 130 | |||
| 131 | if (isset($wrapperNode['errors'])) { |
||
| 132 | $this->_set('errors', new Error\ValidationErrorCollection($wrapperNode['errors'])); |
||
| 133 | $this->_set('message', $wrapperNode['message']); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | } |
||
| 138 |