| Conditions | 24 |
| Paths | 4224 |
| Total Lines | 89 |
| Code Lines | 61 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| 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 |
||
| 64 | public function show(string $parentCategory, string $id = 'All') |
||
| 65 | { |
||
| 66 | $this->setPrefs(); |
||
| 67 | $releases = new Releases(); |
||
| 68 | |||
| 69 | $parentId = RootCategory::query()->where('title', $parentCategory)->value('id'); |
||
| 70 | |||
| 71 | $query = Category::query()->where('title', $id)->where('root_categories_id', $parentId); |
||
| 72 | if ($id !== 'All') { |
||
| 73 | $cat = $query->first(); |
||
| 74 | $category = $cat !== null ? $cat->id : -1; |
||
| 75 | } else { |
||
| 76 | $category = $parentId ?? -1; |
||
| 77 | } |
||
| 78 | |||
| 79 | $grp = -1; |
||
| 80 | |||
| 81 | $catarray = []; |
||
| 82 | $catarray[] = $category; |
||
| 83 | |||
| 84 | $this->smarty->assign('parentcat', ucfirst($parentCategory)); |
||
| 85 | $this->smarty->assign('category', $category); |
||
| 86 | |||
| 87 | $ordering = $releases->getBrowseOrdering(); |
||
| 88 | $orderBy = request()->has('ob') && ! empty(request()->input('ob')) ? request()->input('ob') : ''; |
||
| 89 | $page = request()->has('page') && is_numeric(request()->input('page')) ? request()->input('page') : 1; |
||
| 90 | $offset = ($page - 1) * config('nntmux.items_per_page'); |
||
| 91 | |||
| 92 | $rslt = $releases->getBrowseRange($page, $catarray, $offset, config('nntmux.items_per_page'), $orderBy, -1, $this->userdata->categoryexclusions, $grp); |
||
| 93 | $results = $this->paginate($rslt ?? [], $rslt[0]->_totalcount ?? 0, config('nntmux.items_per_page'), $page, request()->url(), request()->query()); |
||
| 94 | |||
| 95 | $browse = []; |
||
| 96 | |||
| 97 | foreach ($results as $result) { |
||
| 98 | $browse[] = $result; |
||
| 99 | } |
||
| 100 | |||
| 101 | $this->smarty->assign('catname', $id); |
||
| 102 | |||
| 103 | $this->smarty->assign('lastvisit', $this->userdata->lastlogin); |
||
| 104 | |||
| 105 | $this->smarty->assign( |
||
| 106 | [ |
||
| 107 | 'results' => $results, |
||
| 108 | 'resultsadd' => $browse, |
||
| 109 | ] |
||
| 110 | ); |
||
| 111 | |||
| 112 | $covgroup = ''; |
||
| 113 | if ($category === -1 && $grp === -1) { |
||
| 114 | $this->smarty->assign('catname', 'All'); |
||
| 115 | } elseif ($category !== -1 && $grp === -1) { |
||
| 116 | $cdata = Category::find($category); |
||
| 117 | if ($cdata !== null) { |
||
| 118 | if ($cdata->root_categories_id === Category::GAME_ROOT) { |
||
| 119 | $covgroup = 'console'; |
||
| 120 | } elseif ($cdata->root_categories_id === Category::MOVIE_ROOT) { |
||
| 121 | $covgroup = 'movies'; |
||
| 122 | } elseif ($cdata->root_categories_id === Category::XXX_ROOT) { |
||
| 123 | $covgroup = 'xxx'; |
||
| 124 | } elseif ($cdata->root_categories_id === Category::PC_ROOT) { |
||
| 125 | $covgroup = 'games'; |
||
| 126 | } elseif ($cdata->root_categories_id === Category::MUSIC_ROOT) { |
||
| 127 | $covgroup = 'music'; |
||
| 128 | } elseif ($cdata->root_categories_id === Category::BOOKS_ROOT) { |
||
| 129 | $covgroup = 'books'; |
||
| 130 | } |
||
| 131 | } |
||
| 132 | } elseif ($grp !== -1) { |
||
| 133 | $this->smarty->assign('catname', $grp); |
||
| 134 | } |
||
| 135 | |||
| 136 | if ($id === 'All' && $parentCategory === 'All') { |
||
| 137 | $meta_title = 'Browse '.$parentCategory.' releases'; |
||
| 138 | foreach ($ordering as $orderType) { |
||
| 139 | $this->smarty->assign('orderby'.$orderType, url('browse/'.$parentCategory.'?ob='.$orderType)); |
||
| 140 | } |
||
| 141 | } else { |
||
| 142 | $meta_title = 'Browse '.$parentCategory.' / '.$id.' releases'; |
||
| 143 | foreach ($ordering as $orderType) { |
||
| 144 | $this->smarty->assign('orderby'.$orderType, url('browse/'.$parentCategory.'/'.$id.'?ob='.$orderType)); |
||
| 145 | } |
||
| 146 | } |
||
| 147 | $meta_keywords = 'browse,nzb,description,details'; |
||
| 148 | $meta_description = 'Browse for Nzbs'; |
||
| 149 | |||
| 150 | $content = $this->smarty->fetch('browse.tpl'); |
||
| 151 | $this->smarty->assign(compact('content', 'covgroup', 'meta_title', 'meta_keywords', 'meta_description')); |
||
| 152 | $this->pagerender(); |
||
| 153 | } |
||
| 234 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.