Conditions | 5 |
Paths | 9 |
Total Lines | 74 |
Code Lines | 39 |
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 |
||
23 | public function send_message() { |
||
24 | $isPersonalSet=Input::get('isPersonalFlag'); |
||
25 | $rules = array('body' => 'required'); |
||
26 | $validator = Validator::make(Input::all(), $rules); |
||
27 | |||
28 | if($validator->fails()) { |
||
29 | return Response::json([ |
||
30 | 'success' => false, |
||
31 | 'result' => $validator->messages() |
||
32 | ]); |
||
33 | } |
||
34 | |||
35 | |||
36 | |||
37 | $params = array( |
||
38 | 'channel_id' => Input::get('channelId'), |
||
39 | 'body' => Input::get('body'), |
||
40 | 'user_id' => Input::get('user_id') |
||
41 | |||
42 | ); |
||
43 | //decode team id |
||
44 | $team_decoded_id = DB::table('team_channels')->where('team_channel_id', Input::get('channelId'))->first(); |
||
45 | /** |
||
46 | * |
||
47 | * Get the id of the last inserted message |
||
48 | */ |
||
49 | if (strpos(Input::get('body'), '<img') !== false) { |
||
50 | $lastId= DB::table('messages')->insertGetId( |
||
51 | ['message' => strip_tags( Input::get('body'),'<img></img><img /><p></p><br/><br><span></span></code><code><table><td></td><tr></tr><a></a>')] |
||
52 | ); |
||
53 | } |
||
54 | else{ |
||
55 | $lastId= DB::table('messages')->insertGetId( |
||
56 | ['message' => strip_tags(preg_replace("/<([a-z][a-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', Input::get('body')),'<img></img><img /><p></p><br/><br><span></span></code><code><table><td></td><tr></tr><a></a>')] |
||
57 | );} |
||
58 | |||
59 | |||
60 | /** |
||
61 | * if personal flag is set to true insert into personal conversations |
||
62 | * |
||
63 | */ |
||
64 | if($isPersonalSet){ |
||
65 | $teamChannelId=explode("_",Input::get('channelId')); |
||
66 | |||
67 | DB::table('personal_conversations')->insert( |
||
68 | ['team_channel_id' => $teamChannelId[1], 'to_user_id' => Input::get('toUserId'),'from_user_id' => Auth::user()->id,'message_id' => $lastId,'read_status'=>1] |
||
69 | ); |
||
70 | } |
||
71 | else{ |
||
72 | DB::table('team_conversations')->insert( |
||
73 | ['team_channel_id' => Input::get('channelId'), 'user_id' => Input::get('userId'),'message_id' => $lastId] |
||
74 | ); |
||
75 | $this->insertIntoTeamConversationReadStatus(Input::get('channelId'),$lastId); |
||
76 | } |
||
77 | // Publish Data To Redis |
||
78 | |||
79 | if($isPersonalSet){ |
||
80 | $data = array( |
||
81 | 'room' => Input::get('channelId'), |
||
82 | 'message' => array( 'body' => Input::get('body'),'to_channel_id'=>Auth::user()->id."_".$teamChannelId[1], 'user_id' => Auth::user()->id,'first_name'=> Session::get('firstName'),'last_name'=> Session::get('lastName'),'profile_pic'=> Session::get('profilePic'),'message_id'=>$lastId ,'to_user_id'=>Input::get('toUserId')) |
||
83 | ); |
||
84 | Event::fire(ChatMessagesEventHandler::EVENT, array(json_encode($data))); |
||
85 | } |
||
86 | else{ |
||
87 | $data = array( |
||
88 | 'room' => Input::get('channelId'), |
||
89 | 'message' => array( 'body' => Input::get('body'), 'user_id' => Input::get('userId'),'first_name'=> Session::get('firstName'),'last_name'=> Session::get('lastName'),'profile_pic'=> Session::get('profilePic'),'team_encoded_id'=> Input::get('channelId'),'team_decoded_id'=> $team_decoded_id['id'],'message_id'=>$lastId) |
||
90 | ); |
||
91 | Event::fire(ChatConversationsEventHandler::EVENT, array(json_encode($data))); |
||
92 | |||
93 | } |
||
94 | return Response::json([ |
||
95 | 'success' => true, |
||
96 | 'result' => $data |
||
97 | ]); |
||
122 |
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