Conditions | 4 |
Paths | 5 |
Total Lines | 59 |
Code Lines | 38 |
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 |
||
138 | public function export(Request $request): void |
||
139 | { |
||
140 | $this->setAdminPrefs(); |
||
141 | $rel = new Releases; |
||
142 | |||
143 | if ($this->isPostBack($request)) { |
||
144 | $path = $request->input('folder'); |
||
145 | $postFrom = ($request->input('postfrom') ?? ''); |
||
146 | $postTo = ($request->input('postto') ?? ''); |
||
147 | $group = ($request->input('group') === '-1' ? 0 : (int) $request->input('group')); |
||
148 | $gzip = ($request->input('gzip') === '1'); |
||
149 | |||
150 | if ($path !== '') { |
||
151 | $NE = new NZBExport([ |
||
152 | 'Browser' => true, 'Settings' => null, |
||
153 | 'Releases' => $rel, |
||
154 | ]); |
||
155 | $retVal = $NE->beginExport( |
||
156 | [ |
||
157 | $path, |
||
158 | $postFrom, |
||
159 | $postTo, |
||
160 | $group, |
||
161 | $gzip, |
||
162 | ] |
||
163 | ); |
||
164 | } else { |
||
165 | $retVal = 'Error, a path is required!'; |
||
166 | } |
||
167 | |||
168 | $this->smarty->assign( |
||
169 | [ |
||
170 | 'folder' => $path, |
||
171 | 'output' => $retVal, |
||
172 | 'fromdate' => $postFrom, |
||
173 | 'todate' => $postTo, |
||
174 | 'group' => $request->input('group'), |
||
175 | 'gzip' => $request->input('gzip'), |
||
176 | ] |
||
177 | ); |
||
178 | } else { |
||
179 | $this->smarty->assign( |
||
180 | [ |
||
181 | 'fromdate' => $rel->getEarliestUsenetPostDate(), |
||
182 | 'todate' => $rel->getLatestUsenetPostDate(), |
||
183 | ] |
||
184 | ); |
||
185 | } |
||
186 | |||
187 | $meta_title = $title = 'Export Nzbs'; |
||
188 | $this->smarty->assign( |
||
189 | [ |
||
190 | 'gziplist' => [1 => 'True', 0 => 'False'], |
||
191 | 'grouplist' => $rel->getReleasedGroupsForSelect(true), |
||
192 | ] |
||
193 | ); |
||
194 | $content = $this->smarty->fetch('nzb-export.tpl'); |
||
195 | $this->smarty->assign(compact('title', 'meta_title', 'content')); |
||
196 | $this->adminrender(); |
||
197 | } |
||
199 |