Conditions | 10 |
Paths | 132 |
Total Lines | 98 |
Code Lines | 59 |
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 |
||
27 | public function index() |
||
28 | { |
||
29 | if ($this->customer->isLogged()) { |
||
30 | $this->response->redirect($this->url->link('account/account', '', true)); |
||
31 | } |
||
32 | |||
33 | if (isset($this->request->get['code'])) { |
||
34 | $code = $this->request->get['code']; |
||
35 | } else { |
||
36 | $code = ''; |
||
37 | } |
||
38 | |||
39 | $this->load->model('account/customer'); |
||
40 | |||
41 | $customer_info = $this->model_account_customer->getCustomerByCode($code); |
||
42 | |||
43 | if ($customer_info) { |
||
44 | $this->load->language('account/reset'); |
||
45 | |||
46 | $this->document->setTitle($this->language->get('heading_title')); |
||
47 | |||
48 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { |
||
49 | $this->model_account_customer->editPassword($customer_info['email'], $this->request->post['password']); |
||
50 | |||
51 | $this->session->data['success'] = $this->language->get('text_success'); |
||
52 | |||
53 | $this->response->redirect($this->url->link('account/login', '', true)); |
||
54 | } |
||
55 | |||
56 | $data['heading_title'] = $this->language->get('heading_title'); |
||
57 | |||
58 | $data['text_password'] = $this->language->get('text_password'); |
||
59 | |||
60 | $data['entry_password'] = $this->language->get('entry_password'); |
||
61 | $data['entry_confirm'] = $this->language->get('entry_confirm'); |
||
62 | |||
63 | $data['button_continue'] = $this->language->get('button_continue'); |
||
64 | $data['button_back'] = $this->language->get('button_back'); |
||
65 | |||
66 | $data['breadcrumbs'] = array(); |
||
67 | |||
68 | $data['breadcrumbs'][] = array( |
||
69 | 'text' => $this->language->get('text_home'), |
||
70 | 'href' => $this->url->link('common/home') |
||
71 | ); |
||
72 | |||
73 | $data['breadcrumbs'][] = array( |
||
74 | 'text' => $this->language->get('text_account'), |
||
75 | 'href' => $this->url->link('account/account', '', true) |
||
76 | ); |
||
77 | |||
78 | $data['breadcrumbs'][] = array( |
||
79 | 'text' => $this->language->get('heading_title'), |
||
80 | 'href' => $this->url->link('account/reset', '', true) |
||
81 | ); |
||
82 | |||
83 | if (isset($this->error['password'])) { |
||
84 | $data['error_password'] = $this->error['password']; |
||
85 | } else { |
||
86 | $data['error_password'] = ''; |
||
87 | } |
||
88 | |||
89 | if (isset($this->error['confirm'])) { |
||
90 | $data['error_confirm'] = $this->error['confirm']; |
||
91 | } else { |
||
92 | $data['error_confirm'] = ''; |
||
93 | } |
||
94 | |||
95 | $data['action'] = $this->url->link('account/reset', 'code=' . $code, true); |
||
96 | |||
97 | $data['back'] = $this->url->link('account/login', '', true); |
||
98 | |||
99 | if (isset($this->request->post['password'])) { |
||
100 | $data['password'] = $this->request->post['password']; |
||
101 | } else { |
||
102 | $data['password'] = ''; |
||
103 | } |
||
104 | |||
105 | if (isset($this->request->post['confirm'])) { |
||
106 | $data['confirm'] = $this->request->post['confirm']; |
||
107 | } else { |
||
108 | $data['confirm'] = ''; |
||
109 | } |
||
110 | |||
111 | $data['column'] = $this->load->controller('common/column'); |
||
112 | |||
113 | $data['content_top'] = $this->load->controller('common/content_top'); |
||
114 | $data['content_bottom'] = $this->load->controller('common/content_bottom'); |
||
115 | $data['footer'] = $this->load->controller('common/footer'); |
||
116 | $data['header'] = $this->load->controller('common/header'); |
||
117 | |||
118 | $this->response->setOutput($this->load->view('account/reset', $data)); |
||
119 | } else { |
||
120 | $this->load->language('account/reset'); |
||
121 | |||
122 | $this->session->data['error'] = $this->language->get('error_code'); |
||
123 | |||
124 | return new \Divine\Engine\Core\Action('account/login'); |
||
125 | } |
||
141 |
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.