| Conditions | 10 | 
| Paths | 68 | 
| Total Lines | 39 | 
| Code Lines | 22 | 
| Lines | 6 | 
| Ratio | 15.38 % | 
| 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  | 
            ||
| 68 | public static function update(array $data, DiscussConversation $conversation): DiscussConversation  | 
            ||
| 69 |     { | 
            ||
| 70 |         if (Auth::user()->hasPermission('manage.discuss.conversations')) { | 
            ||
| 71 | $data['is_pinned'] = isset($data['is_pinned']) ? true : false;  | 
            ||
| 72 | $data['is_locked'] = isset($data['is_locked']) ? true : false;  | 
            ||
| 73 | |||
| 74 | View Code Duplication |             if ($conversation->is_pinned != $data['is_pinned'] && $data['is_pinned'] == true) { | 
            |
| 75 | event(new ConversationWasPinnedEvent($conversation, Auth::user()));  | 
            ||
| 76 | }  | 
            ||
| 77 | |||
| 78 | View Code Duplication |             if ($conversation->is_locked != $data['is_locked'] && $data['is_locked'] == true) { | 
            |
| 79 | event(new ConversationWasLockedEvent($conversation, Auth::user()));  | 
            ||
| 80 | }  | 
            ||
| 81 | |||
| 82 | $conversation->is_locked = $data['is_locked'];  | 
            ||
| 83 | $conversation->is_pinned = $data['is_pinned'];  | 
            ||
| 84 | }  | 
            ||
| 85 | |||
| 86 |         if ($conversation->title != $data['title']) { | 
            ||
| 87 | event(new TitleWasChangedEvent($conversation, $data['title'], $conversation->title));  | 
            ||
| 88 | |||
| 89 | $conversation->title = $data['title'];  | 
            ||
| 90 | }  | 
            ||
| 91 | |||
| 92 |         if ($conversation->category_id != $data['category_id']) { | 
            ||
| 93 | event(new CategoryWasChangedEvent($conversation, $data['category_id'], $conversation->category_id));  | 
            ||
| 94 | |||
| 95 | $conversation->category_id = $data['category_id'];  | 
            ||
| 96 | }  | 
            ||
| 97 | |||
| 98 | $conversation->is_edited = true;  | 
            ||
| 99 | $conversation->edit_count++;  | 
            ||
| 100 | $conversation->edited_user_id = Auth::id();  | 
            ||
| 101 | $conversation->edited_at = Carbon::now();  | 
            ||
| 102 | |||
| 103 | $conversation->save();  | 
            ||
| 104 | |||
| 105 | return $conversation;  | 
            ||
| 106 | }  | 
            ||
| 107 | |||
| 123 | 
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.