| Conditions | 3 | 
| Paths | 3 | 
| Total Lines | 56 | 
| Code Lines | 30 | 
| 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 | ||
| 94 |     public function store() { | ||
| 95 | |||
| 96 | $rules = array( | ||
| 97 | 'users' => 'required|array', | ||
| 98 | 'body' => 'required' | ||
| 99 | ); | ||
| 100 | |||
| 101 |         $validator = Validator::make(Input::only('users', 'body'), $rules); | ||
| 102 | |||
| 103 |         if ($validator->fails()) { | ||
| 104 | return Response::json([ | ||
| 105 | 'success' => false, | ||
| 106 | 'result' => $validator->messages() | ||
| 107 | ]); | ||
| 108 | } | ||
| 109 | |||
| 110 | // Create Conversation | ||
| 111 | $params = array( | ||
| 112 | 'created_at' => new DateTime, | ||
| 113 | 'name' => str_random(30), | ||
| 114 | 'author_id' => Auth::user()->id | ||
| 115 | ); | ||
| 116 | |||
| 117 | $conversation = Conversation::create($params); | ||
| 118 | |||
| 119 |         $conversation->users()->attach(Input::get('users')); | ||
| 120 | $conversation->users()->attach(array(Auth::user()->id)); | ||
| 121 | |||
| 122 | // Create Message | ||
| 123 | $params = array( | ||
| 124 | 'conversation_id' => $conversation->id, | ||
| 125 |             'body' => Input::get('body'), | ||
| 126 | 'user_id' => Auth::user()->id, | ||
| 127 | 'created_at' => new DateTime | ||
| 128 | ); | ||
| 129 | |||
| 130 | $message = Message::create($params); | ||
| 131 | |||
| 132 | // Create Message Notifications | ||
| 133 | $messages_notifications = array(); | ||
| 134 | |||
| 135 |         foreach (Input::get('users') as $user_id) { | ||
| 136 |             array_push($messages_notifications, new MessageNotification(array('user_id' => $user_id, 'read' => false, 'conversation_id' => $conversation->id))); | ||
| 137 | |||
| 138 | // Publish Data To Redis | ||
| 139 | $data = array( | ||
| 140 | 'room' => $user_id, | ||
| 141 |                 'message' => array('conversation_id' => $conversation->id) | ||
| 142 | ); | ||
| 143 | |||
| 144 | Event::fire(ChatConversationsEventHandler::EVENT, array(json_encode($data))); | ||
| 145 | } | ||
| 146 | |||
| 147 | $message->messages_notifications()->saveMany($messages_notifications); | ||
| 148 | |||
| 149 |         return Redirect::route('chat.index', array('conversation', $conversation->name)); | ||
| 150 | } | ||
| 162 | 
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths