| Conditions | 24 |
| Paths | > 20000 |
| Total Lines | 163 |
| Code Lines | 110 |
| 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 |
||
| 25 | public function index() |
||
| 26 | { |
||
| 27 | $this->load->language('checkout/checkout'); |
||
| 28 | |||
| 29 | $data['text_select'] = $this->language->get('text_select'); |
||
| 30 | $data['text_none'] = $this->language->get('text_none'); |
||
| 31 | $data['text_your_details'] = $this->language->get('text_your_details'); |
||
| 32 | $data['text_your_account'] = $this->language->get('text_your_account'); |
||
| 33 | $data['text_your_address'] = $this->language->get('text_your_address'); |
||
| 34 | $data['text_loading'] = $this->language->get('text_loading'); |
||
| 35 | |||
| 36 | $data['entry_firstname'] = $this->language->get('entry_firstname'); |
||
| 37 | $data['entry_lastname'] = $this->language->get('entry_lastname'); |
||
| 38 | $data['entry_email'] = $this->language->get('entry_email'); |
||
| 39 | $data['entry_telephone'] = $this->language->get('entry_telephone'); |
||
| 40 | $data['entry_fax'] = $this->language->get('entry_fax'); |
||
| 41 | $data['entry_company'] = $this->language->get('entry_company'); |
||
| 42 | $data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
||
| 43 | $data['entry_address_1'] = $this->language->get('entry_address_1'); |
||
| 44 | $data['entry_address_2'] = $this->language->get('entry_address_2'); |
||
| 45 | $data['entry_postcode'] = $this->language->get('entry_postcode'); |
||
| 46 | $data['entry_city'] = $this->language->get('entry_city'); |
||
| 47 | $data['entry_country'] = $this->language->get('entry_country'); |
||
| 48 | $data['entry_zone'] = $this->language->get('entry_zone'); |
||
| 49 | $data['entry_shipping'] = $this->language->get('entry_shipping'); |
||
| 50 | |||
| 51 | $data['button_continue'] = $this->language->get('button_continue'); |
||
| 52 | $data['button_upload'] = $this->language->get('button_upload'); |
||
| 53 | |||
| 54 | $data['customer_groups'] = array(); |
||
| 55 | |||
| 56 | if (is_array($this->config->get('config_customer_group_display'))) { |
||
| 57 | $this->load->model('account/customer_group'); |
||
| 58 | |||
| 59 | $customer_groups = $this->model_account_customer_group->getCustomerGroups(); |
||
| 60 | |||
| 61 | foreach ($customer_groups as $customer_group) { |
||
| 62 | if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
||
| 63 | $data['customer_groups'][] = $customer_group; |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | if (isset($this->session->data['guest']['customer_group_id'])) { |
||
| 69 | $data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; |
||
| 70 | } else { |
||
| 71 | $data['customer_group_id'] = $this->config->get('config_customer_group_id'); |
||
| 72 | } |
||
| 73 | |||
| 74 | if (isset($this->session->data['guest']['firstname'])) { |
||
| 75 | $data['firstname'] = $this->session->data['guest']['firstname']; |
||
| 76 | } else { |
||
| 77 | $data['firstname'] = ''; |
||
| 78 | } |
||
| 79 | |||
| 80 | if (isset($this->session->data['guest']['lastname'])) { |
||
| 81 | $data['lastname'] = $this->session->data['guest']['lastname']; |
||
| 82 | } else { |
||
| 83 | $data['lastname'] = ''; |
||
| 84 | } |
||
| 85 | |||
| 86 | if (isset($this->session->data['guest']['email'])) { |
||
| 87 | $data['email'] = $this->session->data['guest']['email']; |
||
| 88 | } else { |
||
| 89 | $data['email'] = ''; |
||
| 90 | } |
||
| 91 | |||
| 92 | if (isset($this->session->data['guest']['telephone'])) { |
||
| 93 | $data['telephone'] = $this->session->data['guest']['telephone']; |
||
| 94 | } else { |
||
| 95 | $data['telephone'] = ''; |
||
| 96 | } |
||
| 97 | |||
| 98 | if (isset($this->session->data['guest']['fax'])) { |
||
| 99 | $data['fax'] = $this->session->data['guest']['fax']; |
||
| 100 | } else { |
||
| 101 | $data['fax'] = ''; |
||
| 102 | } |
||
| 103 | |||
| 104 | if (isset($this->session->data['payment_address']['company'])) { |
||
| 105 | $data['company'] = $this->session->data['payment_address']['company']; |
||
| 106 | } else { |
||
| 107 | $data['company'] = ''; |
||
| 108 | } |
||
| 109 | |||
| 110 | if (isset($this->session->data['payment_address']['address_1'])) { |
||
| 111 | $data['address_1'] = $this->session->data['payment_address']['address_1']; |
||
| 112 | } else { |
||
| 113 | $data['address_1'] = ''; |
||
| 114 | } |
||
| 115 | |||
| 116 | if (isset($this->session->data['payment_address']['address_2'])) { |
||
| 117 | $data['address_2'] = $this->session->data['payment_address']['address_2']; |
||
| 118 | } else { |
||
| 119 | $data['address_2'] = ''; |
||
| 120 | } |
||
| 121 | |||
| 122 | if (isset($this->session->data['payment_address']['postcode'])) { |
||
| 123 | $data['postcode'] = $this->session->data['payment_address']['postcode']; |
||
| 124 | } elseif (isset($this->session->data['shipping_address']['postcode'])) { |
||
| 125 | $data['postcode'] = $this->session->data['shipping_address']['postcode']; |
||
| 126 | } else { |
||
| 127 | $data['postcode'] = ''; |
||
| 128 | } |
||
| 129 | |||
| 130 | if (isset($this->session->data['payment_address']['city'])) { |
||
| 131 | $data['city'] = $this->session->data['payment_address']['city']; |
||
| 132 | } else { |
||
| 133 | $data['city'] = ''; |
||
| 134 | } |
||
| 135 | |||
| 136 | if (isset($this->session->data['payment_address']['country_id'])) { |
||
| 137 | $data['country_id'] = $this->session->data['payment_address']['country_id']; |
||
| 138 | } elseif (isset($this->session->data['shipping_address']['country_id'])) { |
||
| 139 | $data['country_id'] = $this->session->data['shipping_address']['country_id']; |
||
| 140 | } else { |
||
| 141 | $data['country_id'] = $this->config->get('config_country_id'); |
||
| 142 | } |
||
| 143 | |||
| 144 | if (isset($this->session->data['payment_address']['zone_id'])) { |
||
| 145 | $data['zone_id'] = $this->session->data['payment_address']['zone_id']; |
||
| 146 | } elseif (isset($this->session->data['shipping_address']['zone_id'])) { |
||
| 147 | $data['zone_id'] = $this->session->data['shipping_address']['zone_id']; |
||
| 148 | } else { |
||
| 149 | $data['zone_id'] = ''; |
||
| 150 | } |
||
| 151 | |||
| 152 | $this->load->model('localisation/country'); |
||
| 153 | |||
| 154 | $data['countries'] = $this->model_localisation_country->getCountries(); |
||
| 155 | |||
| 156 | // Custom Fields |
||
| 157 | $this->load->model('account/custom_field'); |
||
| 158 | |||
| 159 | $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); |
||
| 160 | |||
| 161 | if (isset($this->session->data['guest']['custom_field'])) { |
||
| 162 | if (isset($this->session->data['guest']['custom_field'])) { |
||
| 163 | $guest_custom_field = $this->session->data['guest']['custom_field']; |
||
| 164 | } else { |
||
| 165 | $guest_custom_field = array(); |
||
| 166 | } |
||
| 167 | |||
| 168 | if (isset($this->session->data['payment_address']['custom_field'])) { |
||
| 169 | $address_custom_field = $this->session->data['payment_address']['custom_field']; |
||
| 170 | } else { |
||
| 171 | $address_custom_field = array(); |
||
| 172 | } |
||
| 173 | |||
| 174 | $data['guest_custom_field'] = $guest_custom_field + $address_custom_field; |
||
| 175 | } else { |
||
| 176 | $data['guest_custom_field'] = array(); |
||
| 177 | } |
||
| 178 | |||
| 179 | $data['shipping_required'] = $this->cart->hasShipping(); |
||
| 180 | |||
| 181 | if (isset($this->session->data['guest']['shipping_address'])) { |
||
| 182 | $data['shipping_address'] = $this->session->data['guest']['shipping_address']; |
||
| 183 | } else { |
||
| 184 | $data['shipping_address'] = true; |
||
| 185 | } |
||
| 186 | |||
| 187 | $this->response->setOutput($this->load->view('checkout/guest', $data)); |
||
| 188 | } |
||
| 387 |
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.