Conditions | 17 |
Paths | 17 |
Total Lines | 41 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 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 |
||
19 | public function checkMsgFormate($msg) |
||
20 | { |
||
21 | if (!isset($msg['agentid'])) { |
||
22 | throw new \Exception('请传入部门ID'); |
||
23 | } |
||
24 | |||
25 | if (!isset($msg['msgtype'])) { |
||
26 | throw new \Exception('消息类型未传入'); |
||
27 | } |
||
28 | |||
29 | if ('textcard' == $msg['msgtype']) { |
||
30 | if (!isset($msg['textcard'])) { |
||
31 | throw new \Exception('未传入消息主体'); |
||
32 | } |
||
33 | |||
34 | if (!isset($msg['textcard']['title'])) { |
||
35 | throw new \Exception('未设置标题'); |
||
36 | } |
||
37 | |||
38 | if (!isset($msg['textcard']['description'])) { |
||
39 | throw new \Exception('未设置描述'); |
||
40 | } |
||
41 | |||
42 | if (!isset($msg['textcard']['url'])) { |
||
43 | throw new \Exception('未设置跳转链接'); |
||
44 | } |
||
45 | } elseif ('text' == $msg['msgtype']) { |
||
46 | if (!isset($msg['text'])) { |
||
47 | throw new \Exception('未传入消息主体'); |
||
48 | } |
||
49 | if (!isset($msg['text']['content'])) { |
||
50 | throw new \Exception('未设置消息内容'); |
||
51 | } |
||
52 | } |
||
53 | |||
54 | if (!isset($msg['touser']) && !isset($msg['toparty']) && !isset($msg['totag'])) { |
||
55 | throw new \Exception('未设置接收人'); |
||
56 | } |
||
57 | |||
58 | if (empty($msg['touser']) && empty($msg['toparty']) && empty($msg['totag'])) { |
||
59 | throw new \Exception('接收人不能为空'); |
||
60 | } |
||
112 |
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