Conditions | 5 |
Paths | 18 |
Total Lines | 64 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
97 | public function update($sort_by = 'create_date', $order = 'asc') { |
||
98 | $this->load->library('pagination'); |
||
99 | |||
100 | // Show upgrade window; |
||
101 | try { |
||
102 | |||
103 | $status = $this->update->getStatus(); |
||
104 | $result = $this->update->getHashSum(); |
||
105 | |||
106 | } catch (Exception $e) { |
||
107 | |||
108 | $result['error'] = $e->getMessage(); |
||
109 | $this->lib_admin->log($result['error']); |
||
110 | } |
||
111 | // Create pagination |
||
112 | $filesCount = count($result); |
||
113 | $config['base_url'] = '/admin/sys_update/update?'; |
||
114 | $config['page_query_string'] = true; |
||
115 | $config['uri_segment'] = 3; |
||
116 | $config['total_rows'] = $filesCount; |
||
117 | $config['per_page'] = 25; |
||
118 | $config['full_tag_open'] = '<div class="pagination pull-left"><ul>'; |
||
119 | $config['full_tag_close'] = '</ul></div>'; |
||
120 | $config['controls_tag_open'] = '<div class="pagination pull-right"><ul>'; |
||
121 | $config['controls_tag_close'] = '</ul></div>'; |
||
122 | $config['next_link'] = lang('Next', 'admin') . ' >'; |
||
123 | $config['prev_link'] = '< ' . lang('Prev', 'admin'); |
||
124 | $config['cur_tag_open'] = '<li class="btn-primary active"><span>'; |
||
125 | $config['cur_tag_close'] = '</span></li>'; |
||
126 | $config['prev_tag_open'] = '<li>'; |
||
127 | $config['prev_tag_close'] = '</li>'; |
||
128 | $config['next_tag_open'] = '<li>'; |
||
129 | $config['next_tag_close'] = '</li>'; |
||
130 | $config['num_tag_close'] = '</li>'; |
||
131 | $config['num_tag_open'] = '<li>'; |
||
132 | $config['num_tag_close'] = '</li>'; |
||
133 | $config['last_tag_open'] = '<li>'; |
||
134 | $config['last_tag_close'] = '</li>'; |
||
135 | $config['first_tag_open'] = '<li>'; |
||
136 | $config['first_tag_close'] = '</li>'; |
||
137 | |||
138 | $result = array_chunk($result , 25 , true); |
||
139 | $this->pagination->initialize($config); |
||
140 | |||
141 | $page_num = $this->input->get('per_page') >= 25 ? $this->input->get('per_page') / 25 : 0; |
||
142 | if (!$result[0]['error']) { |
||
143 | $data = [ |
||
144 | 'paginator' => $this->pagination->create_links_ajax(), |
||
145 | 'filesCount' => $filesCount, |
||
146 | 'sort_by' => $sort_by, |
||
147 | 'order' => $order, |
||
148 | 'diff_files_dates' => $this->update->get_files_dates(), |
||
149 | 'diff_files' => $result[$page_num] , |
||
150 | 'restore_files' => $this->sort($this->update->restore_files_list(), $sort_by, $order), |
||
151 | 'new_version' => $status ? TRUE : FALSE |
||
152 | ]; |
||
153 | } else { |
||
154 | $data = [ |
||
155 | 'restore_files' => $this->sort($this->update->restore_files_list(), $sort_by, $order), |
||
156 | 'error' => $result[0]['error'] |
||
157 | ]; |
||
158 | } |
||
159 | $this->template->show('sys_update', FALSE, $data); |
||
160 | } |
||
161 | |||
308 | } |