Conditions | 11 |
Paths | 115 |
Total Lines | 35 |
Code Lines | 20 |
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 |
||
113 | public function setDetails(array $details) |
||
114 | { |
||
115 | if (isset($details['liabilityShift'])) { |
||
116 | if (!in_array($details['liabilityShift'], self::LIABILITY_SHIFTS)) { |
||
117 | throw AuthenticationException::invalidLiabilityShift($details['liabilityShift']); |
||
118 | } |
||
119 | $this->details['liabilityShift'] = $details['liabilityShift']; |
||
120 | } |
||
121 | |||
122 | if (isset($details['merchantPreference'])) { |
||
123 | if (!in_array($details['merchantPreference'], self::MERCHANT_PREFERENCES)) { |
||
124 | throw AuthenticationException::invalidMerchantPreference($details['merchantPreference']); |
||
125 | } |
||
126 | $this->details['merchantPreference'] = $details['merchantPreference']; |
||
127 | } |
||
128 | |||
129 | if (isset($details['transactionID'])) { |
||
130 | $this->details['transactionID'] = $details['transactionID']; |
||
131 | } |
||
132 | if (isset($details['authenticationValue'])) { |
||
133 | $this->details['authenticationValue'] = $details['authenticationValue']; |
||
134 | } |
||
135 | |||
136 | if (isset($details['status3DS'])) { |
||
137 | if (!in_array($details['status3DS'], self::DDDS_STATUSES)) { |
||
138 | throw AuthenticationException::invalidDDDSStatus($details['status3DS']); |
||
139 | } |
||
140 | $this->details['status3DS'] = $details['status3DS']; |
||
141 | } |
||
142 | |||
143 | if (isset($details['disablingReason'])) { |
||
144 | if (!in_array($details['disablingReason'], self::DISABLING_REASONS)) { |
||
145 | throw AuthenticationException::invalidDisablingReason($details['disablingReason']); |
||
146 | } |
||
147 | $this->details['disablingReason'] = $details['disablingReason']; |
||
148 | } |
||
186 |