| Conditions | 12 |
| Paths | 2048 |
| Total Lines | 121 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 27 |
| CRAP Score | 12 |
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 |
||
| 115 | 1 | public static function getCreditCardForm($amount, $fp_sequence, $relay_response_url, $api_login_id, $transaction_key, $test_mode = true, $prefill = true) |
|
| 116 | { |
||
| 117 | 1 | $time = time(); |
|
| 118 | 1 | $fp = self::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $time); |
|
| 119 | 1 | $sim = new AuthorizeNetSIM_Form( |
|
| 120 | array( |
||
| 121 | 1 | 'x_amount' => $amount, |
|
| 122 | 1 | 'x_fp_sequence' => $fp_sequence, |
|
| 123 | 1 | 'x_fp_hash' => $fp, |
|
| 124 | 1 | 'x_fp_timestamp' => $time, |
|
| 125 | 1 | 'x_relay_response'=> "TRUE", |
|
| 126 | 1 | 'x_relay_url' => $relay_response_url, |
|
| 127 | 1 | 'x_login' => $api_login_id, |
|
| 128 | ) |
||
| 129 | ); |
||
| 130 | 1 | $hidden_fields = $sim->getHiddenFieldString(); |
|
| 131 | 1 | $post_url = ($test_mode ? self::SANDBOX_URL : self::LIVE_URL); |
|
| 132 | |||
| 133 | $form = ' |
||
| 134 | <style> |
||
| 135 | fieldset { |
||
| 136 | overflow: auto; |
||
| 137 | border: 0; |
||
| 138 | margin: 0; |
||
| 139 | padding: 0; } |
||
| 140 | |||
| 141 | fieldset div { |
||
| 142 | float: left; } |
||
| 143 | |||
| 144 | fieldset.centered div { |
||
| 145 | text-align: center; } |
||
| 146 | |||
| 147 | label { |
||
| 148 | color: #183b55; |
||
| 149 | display: block; |
||
| 150 | margin-bottom: 5px; } |
||
| 151 | |||
| 152 | label img { |
||
| 153 | display: block; |
||
| 154 | margin-bottom: 5px; } |
||
| 155 | |||
| 156 | input.text { |
||
| 157 | border: 1px solid #bfbab4; |
||
| 158 | margin: 0 4px 8px 0; |
||
| 159 | padding: 6px; |
||
| 160 | color: #1e1e1e; |
||
| 161 | -webkit-border-radius: 5px; |
||
| 162 | -moz-border-radius: 5px; |
||
| 163 | border-radius: 5px; |
||
| 164 | -webkit-box-shadow: inset 0px 5px 5px #eee; |
||
| 165 | -moz-box-shadow: inset 0px 5px 5px #eee; |
||
| 166 | box-shadow: inset 0px 5px 5px #eee; } |
||
| 167 | .submit { |
||
| 168 | display: block; |
||
| 169 | background-color: #76b2d7; |
||
| 170 | border: 1px solid #766056; |
||
| 171 | color: #3a2014; |
||
| 172 | margin: 13px 0; |
||
| 173 | padding: 8px 16px; |
||
| 174 | -webkit-border-radius: 12px; |
||
| 175 | -moz-border-radius: 12px; |
||
| 176 | border-radius: 12px; |
||
| 177 | font-size: 14px; |
||
| 178 | -webkit-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); |
||
| 179 | -moz-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); |
||
| 180 | box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); } |
||
| 181 | </style> |
||
| 182 | 1 | <form method="post" action="'.$post_url.'"> |
|
| 183 | 1 | '.$hidden_fields.' |
|
| 184 | <fieldset> |
||
| 185 | <div> |
||
| 186 | <label>Credit Card Number</label> |
||
| 187 | 1 | <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '').'"></input> |
|
| 188 | </div> |
||
| 189 | <div> |
||
| 190 | <label>Exp.</label> |
||
| 191 | 1 | <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '').'"></input> |
|
| 192 | </div> |
||
| 193 | <div> |
||
| 194 | <label>CCV</label> |
||
| 195 | 1 | <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '').'"></input> |
|
| 196 | </div> |
||
| 197 | </fieldset> |
||
| 198 | <fieldset> |
||
| 199 | <div> |
||
| 200 | <label>First Name</label> |
||
| 201 | 1 | <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '').'"></input> |
|
| 202 | </div> |
||
| 203 | <div> |
||
| 204 | <label>Last Name</label> |
||
| 205 | 1 | <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '').'"></input> |
|
| 206 | </div> |
||
| 207 | </fieldset> |
||
| 208 | <fieldset> |
||
| 209 | <div> |
||
| 210 | <label>Address</label> |
||
| 211 | 1 | <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '').'"></input> |
|
| 212 | </div> |
||
| 213 | <div> |
||
| 214 | <label>City</label> |
||
| 215 | 1 | <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '').'"></input> |
|
| 216 | </div> |
||
| 217 | </fieldset> |
||
| 218 | <fieldset> |
||
| 219 | <div> |
||
| 220 | <label>State</label> |
||
| 221 | 1 | <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '').'"></input> |
|
| 222 | </div> |
||
| 223 | <div> |
||
| 224 | <label>Zip Code</label> |
||
| 225 | 1 | <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '').'"></input> |
|
| 226 | </div> |
||
| 227 | <div> |
||
| 228 | <label>Country</label> |
||
| 229 | 1 | <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '').'"></input> |
|
| 230 | </div> |
||
| 231 | </fieldset> |
||
| 232 | <input type="submit" value="BUY" class="submit buy"> |
||
| 233 | 1 | </form>'; |
|
| 234 | 1 | return $form; |
|
| 235 | } |
||
| 236 | |||
| 237 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.