| Conditions | 13 |
| Paths | 16 |
| Total Lines | 40 |
| Code Lines | 23 |
| 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 create(Request $request) |
||
| 40 | { |
||
| 41 | if (! \defined('STDOUT')) { |
||
| 42 | \define('STDOUT', fopen('php://stdout', 'wb')); |
||
| 43 | } |
||
| 44 | $this->setAdminPrefs(); |
||
| 45 | $movie = new Movie(['Settings' => null]); |
||
| 46 | |||
| 47 | $meta_title = $title = 'Movie Add'; |
||
| 48 | |||
| 49 | $id = $request->input('id'); |
||
| 50 | |||
| 51 | if ($request->has('id') && is_numeric($request->input('id'))) { |
||
| 52 | $movCheck = $movie->getMovieInfo($id); |
||
| 53 | $movieInfo = $movie->updateMovieInfo($id); |
||
| 54 | if ($movieInfo && ($movCheck === null || ($request->has('update') && (int) $request->input('update') === 1))) { |
||
| 55 | $forUpdate = Release::query()->where('imdbid', $id)->get(['id']); |
||
| 56 | if ($forUpdate !== null) { |
||
| 57 | $movieInfoId = MovieInfo::query()->where('imdbid', $id)->first(['id']); |
||
| 58 | if ($movieInfoId !== null) { |
||
| 59 | foreach ($forUpdate as $movie) { |
||
| 60 | Release::query()->where('id', $movie->id)->update(['movieinfo_id' => $movieInfoId->id]); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 | if (($request->has('update') && (int) $request->input('update') === 1)) { |
||
| 65 | return back()->withInput(); |
||
| 66 | } |
||
| 67 | |||
| 68 | return redirect('/admin/movie-list'); |
||
| 69 | } |
||
| 70 | |||
| 71 | return redirect('/admin/movie-list'); |
||
| 72 | } |
||
| 73 | |||
| 74 | $content = $this->smarty->fetch('movie-add.tpl'); |
||
| 75 | |||
| 76 | $this->smarty->assign(compact('title', 'meta_title', 'content')); |
||
| 77 | |||
| 78 | $this->adminrender(); |
||
| 79 | } |
||
| 166 |
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.