| Conditions | 12 |
| Paths | 6 |
| Total Lines | 51 |
| Code Lines | 32 |
| 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 |
||
| 39 | public function edit(Request $request) |
||
| 40 | { |
||
| 41 | $this->setAdminPrefs(); |
||
| 42 | $console = new Console(['Settings' => null]); |
||
| 43 | $gen = new Genres(); |
||
| 44 | $meta_title = $title = 'Console Edit'; |
||
| 45 | |||
| 46 | // set the current action |
||
| 47 | $action = $request->input('action') ?? 'view'; |
||
| 48 | |||
| 49 | if ($request->has('id')) { |
||
| 50 | $id = $request->input('id'); |
||
| 51 | $con = $console->getConsoleInfo($id); |
||
| 52 | |||
| 53 | if (! $con) { |
||
| 54 | $this->show404(); |
||
| 55 | } |
||
| 56 | |||
| 57 | switch ($action) { |
||
| 58 | case 'submit': |
||
| 59 | $coverLoc = resource_path().'/covers/console/'.$id.'.jpg'; |
||
| 60 | |||
| 61 | if ($_FILES['cover']['size'] > 0) { |
||
| 62 | $tmpName = $_FILES['cover']['tmp_name']; |
||
| 63 | $file_info = getimagesize($tmpName); |
||
| 64 | if (! empty($file_info)) { |
||
| 65 | move_uploaded_file($_FILES['cover']['tmp_name'], $coverLoc); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | $request->merge(['cover' => file_exists($coverLoc) ? 1 : 0]); |
||
| 70 | $request->merge(['salesrank' => (empty($request->input('salesrank')) || ! ctype_digit($request->input('salesrank'))) ? 'null' : $request->input('salesrank')]); |
||
| 71 | $request->merge(['releasedate' => (empty($request->input('releasedate')) || ! strtotime($request->input('releasedate'))) ? $con['releasedate'] : Carbon::parse($request->input('releasedate'))->timestamp]); |
||
| 72 | |||
| 73 | $console->update($id, $request->input('title'), $request->input('asin'), $request->input('url'), $request->input('salesrank'), $request->input('platform'), $request->input('publisher'), $request->input('releasedate'), $request->input('esrb'), $request->input('cover'), $request->input('genre')); |
||
| 74 | |||
| 75 | return redirect('admin/console-list.'); |
||
| 76 | break; |
||
| 77 | case 'view': |
||
| 78 | default: |
||
| 79 | $this->smarty->assign('console', $con); |
||
| 80 | $this->smarty->assign('genres', $gen->getGenres(Genres::CONSOLE_TYPE)); |
||
| 81 | break; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | |||
| 85 | $content = $this->smarty->fetch('console-edit.tpl'); |
||
| 86 | |||
| 87 | $this->smarty->assign(compact('title', 'meta_title', 'content')); |
||
| 88 | |||
| 89 | $this->adminrender(); |
||
| 90 | } |
||
| 92 |
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.