| Conditions | 2 | 
| Paths | 1 | 
| Total Lines | 55 | 
| Code Lines | 31 | 
| 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  | 
            ||
| 90 | public function move($job, Request $request)  | 
            ||
| 91 |     { | 
            ||
| 92 | $this->validate($request, [  | 
            ||
| 93 | 'forum_id' => 'required|integer|exists:forums,id'  | 
            ||
| 94 | ]);  | 
            ||
| 95 | |||
| 96 |         $forum = $this->forum->find($request->input('forum_id')); | 
            ||
| 97 | /** @var \Coyote\Topic $topic */  | 
            ||
| 98 | $topic = $this->topic->newInstance();  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 99 | /** @var \Coyote\Post $post */  | 
            ||
| 100 | $post = $this->post->newInstance();  | 
            ||
| 101 | |||
| 102 | $topic->fill(['subject' => $job->title]);  | 
            ||
| 103 | $topic->forum()->associate($forum);  | 
            ||
| 104 | |||
| 105 | $log = $this->stream->findWhere(['object.objectType' => 'job', 'object.id' => $job->id, 'verb' => 'create'])->first();  | 
            ||
| 106 | |||
| 107 | $post->forceFill([  | 
            ||
| 108 | 'user_id' => $job->user_id,  | 
            ||
| 109 | 'text' => $job->description,  | 
            ||
| 110 | 'ip' => $log->ip,  | 
            ||
| 111 | 'browser' => $log->browser,  | 
            ||
| 112 | 'host' => gethostbyaddr($log->ip)  | 
            ||
| 113 | ]);  | 
            ||
| 114 | |||
| 115 |         $this->transaction(function () use ($job, $forum, $topic, $post) { | 
            ||
| 116 | $topic->save();  | 
            ||
| 117 | |||
| 118 | $post->forum()->associate($forum);  | 
            ||
| 119 | $post->topic()->associate($topic);  | 
            ||
| 120 | |||
| 121 | $post->save();  | 
            ||
| 122 | |||
| 123 |             if ($job->user_id !== $job->user->id) { | 
            ||
| 124 | $post->subscribers()->create(['user_id' => $job->user_id]);  | 
            ||
| 125 | }  | 
            ||
| 126 | |||
| 127 | $log = new \Coyote\Post\Log();  | 
            ||
| 128 | $log->fillWithPost($post)->fill(['subject' => $topic->subject]);  | 
            ||
| 129 | |||
| 130 | event(new JobDeleting($job));  | 
            ||
| 131 | |||
| 132 | $job->delete();  | 
            ||
| 133 | |||
| 134 | // fire the event. it can be used to index a content and/or add page path to "pages" table  | 
            ||
| 135 | event(new TopicWasSaved($topic));  | 
            ||
| 136 | // add post to elasticsearch  | 
            ||
| 137 | event(new PostWasSaved($post));  | 
            ||
| 138 | |||
| 139 | stream(Stream_Move::class, (new Stream_Job())->map($job), (new Stream_Forum())->map($forum));  | 
            ||
| 140 | });  | 
            ||
| 141 | |||
| 142 | return redirect()  | 
            ||
| 143 | ->to(UrlBuilder::post($post))  | 
            ||
| 144 |             ->with('success', 'Ogłoszenie zostało przeniesione.'); | 
            ||
| 145 | }  | 
            ||
| 147 |