| Conditions | 12 |
| Paths | 34 |
| Total Lines | 46 |
| Code Lines | 30 |
| 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 |
||
| 17 | public function index(Request $request) |
||
| 18 | { |
||
| 19 | $this->setAdminPrefs(); |
||
| 20 | |||
| 21 | $meta_title = $title = 'Sharing Settings'; |
||
| 22 | |||
| 23 | $allSites = SharingSite::query()->orderByDesc('id')->paginate(config('nntmux.items_per_cover_page')); |
||
| 24 | if ($allSites->total() === 0) { |
||
| 25 | $allSites = false; |
||
| 26 | } |
||
| 27 | |||
| 28 | $ourSite = Sharing::query()->first(); |
||
| 29 | |||
| 30 | if (! empty($request->all())) { |
||
| 31 | if (! empty($request->input('sharing_name')) && ! preg_match('/\s+/', $request->input('sharing_name')) && strlen($request->input('sharing_name')) < 255) { |
||
| 32 | $site_name = trim($request->input('sharing_name')); |
||
| 33 | } else { |
||
| 34 | $site_name = $ourSite['site_name']; |
||
| 35 | } |
||
| 36 | if (! empty($request->input('sharing_maxpush')) && is_numeric($request->input('sharing_maxpush'))) { |
||
| 37 | $max_push = trim($request->input('sharing_maxpush')); |
||
| 38 | } else { |
||
| 39 | $max_push = $ourSite['max_push']; |
||
| 40 | } |
||
| 41 | if (! empty($request->input('sharing_maxpoll')) && is_numeric($request->input('sharing_maxpush'))) { |
||
| 42 | $max_pull = trim($request->input('sharing_maxpoll')); |
||
| 43 | } else { |
||
| 44 | $max_pull = $ourSite['max_pull']; |
||
| 45 | } |
||
| 46 | if (! empty($request->input('sharing_maxdownload')) && is_numeric($request->input('sharing_maxdownload'))) { |
||
| 47 | $max_download = trim($request->input('sharing_maxdownload')); |
||
| 48 | } else { |
||
| 49 | $max_download = $ourSite['max_download']; |
||
| 50 | } |
||
| 51 | Sharing::query() |
||
| 52 | ->update(compact('site_name', 'max_push', 'max_pull', 'max_download')); |
||
| 53 | |||
| 54 | $ourSite = $ourSite = Sharing::query()->first(); |
||
|
|
|||
| 55 | } |
||
| 56 | |||
| 57 | $this->smarty->assign(['local' => $ourSite, 'sites' => $allSites]); |
||
| 58 | |||
| 59 | $content = $this->smarty->fetch('sharing.tpl'); |
||
| 60 | |||
| 61 | $this->smarty->assign(compact('title', 'meta_title', 'content')); |
||
| 62 | $this->adminrender(); |
||
| 63 | } |
||
| 65 |