Conditions | 16 |
Paths | 20 |
Total Lines | 86 |
Code Lines | 65 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
18 | public static function send($config) |
||
19 | { |
||
20 | if(!empty($config['type'])){ |
||
21 | if($config['type'] == 1) { //to a leader that member apply to join the group |
||
22 | $messages = Message::where([ |
||
23 | 'receiver' => $config['receiver'], |
||
24 | 'type' => $config['type'], |
||
25 | 'unread' => 1 |
||
26 | ])->get(); |
||
27 | if(!empty($messages)) { |
||
28 | foreach($messages as $message) { |
||
29 | $data = json_decode($message->data,true); |
||
30 | if($data['group']['gcode'] == $config['data']['group']['gcode']) { |
||
31 | array_push($data['user'],$config['data']['user'][0]); |
||
32 | $message->data = json_encode($data); |
||
33 | $message->save(); |
||
34 | return true; |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | }elseif ($config['type'] == 2) { //to a leader that member agree to join the group |
||
39 | $messages = Message::where([ |
||
40 | 'receiver' => $config['receiver'], |
||
41 | 'type' => $config['type'], |
||
42 | 'unread' => 1 |
||
43 | ])->get(); |
||
44 | if(!empty($messages)) { |
||
45 | foreach($messages as $message) { |
||
46 | $data = json_decode($message->data,true); |
||
47 | if($data['group'] == $config['data']['group']) { |
||
48 | array_push($data['user'],$config['data']['user'][0]); |
||
49 | $message->data = json_encode($data); |
||
50 | $message->save(); |
||
51 | return true; |
||
52 | } |
||
53 | } |
||
54 | } |
||
55 | }elseif ($config['type'] == 3) { //to a person that solution was passed |
||
56 | $message = Message::where([ |
||
57 | 'receiver' => $config['receiver'], |
||
58 | 'type' => $config['type'], |
||
59 | 'unread' => 1 |
||
60 | ])->first(); |
||
61 | if(!empty($message)) { |
||
62 | $data = json_decode($message->data,true); |
||
63 | array_push($data,$config['data']); |
||
64 | $message->data = json_encode($data); |
||
65 | $message->save(); |
||
66 | return true; |
||
67 | } |
||
68 | }elseif ($config['type'] == 4) { //to a person that solution was blocked |
||
69 | $message = Message::where([ |
||
70 | 'receiver' => $config['receiver'], |
||
71 | 'type' => $config['type'], |
||
72 | 'unread' => 1 |
||
73 | ])->first(); |
||
74 | if(!empty($message)) { |
||
75 | $data = json_decode($message->data,true); |
||
76 | array_push($data,$config['data']); |
||
77 | $message->data = json_encode($data); |
||
78 | $message->save(); |
||
79 | return true; |
||
80 | } |
||
81 | } |
||
82 | } |
||
83 | $message = new Message; |
||
84 | $message->sender = $config['sender']; |
||
85 | $message->receiver = $config['receiver']; |
||
86 | $message->title = $config['title']; |
||
87 | if(isset($config['data']) && isset($config['type'])){ |
||
88 | $message->type = $config['type'] ?? null; |
||
89 | $message->data = json_encode($config['data']); |
||
90 | }else{ |
||
91 | $message->content = $config['content']; |
||
92 | } |
||
93 | /* |
||
94 | if(isset($config['reply'])){ |
||
95 | $message->reply = $config['reply']; |
||
96 | } |
||
97 | if(isset($config['allow_reply'])){ |
||
98 | $message->reply = $config['allow_reply']; |
||
99 | } |
||
100 | */ |
||
101 | $message->official = 1; |
||
102 | $message->save(); |
||
103 | return true; |
||
104 | } |
||
249 |
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