@@ -113,7 +113,7 @@ |
||
113 | 113 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
114 | 114 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
115 | 115 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 |
116 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 |
|
116 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 |
|
117 | 117 | curl_setopt($ch, CURLOPT_POST, 1); |
118 | 118 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
119 | 119 | curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
@@ -80,16 +80,26 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private function sendMsg(array $data) |
82 | 82 | { |
83 | - if (empty($this->config->get('webhook')) && empty($this->config->get('key'))) throw new QyWeXinException('企业微信自定义机器人接口未配置,【webhook,key】请配置其中一个'); |
|
83 | + if (empty($this->config->get('webhook')) && empty($this->config->get('key'))) { |
|
84 | + throw new QyWeXinException('企业微信自定义机器人接口未配置,【webhook,key】请配置其中一个'); |
|
85 | + } |
|
84 | 86 | if (!empty($this->config->get('webhook'))) { |
85 | - if (empty($data['msgtype'])) $data['msgtype'] = $this->msgType; |
|
87 | + if (empty($data['msgtype'])) { |
|
88 | + $data['msgtype'] = $this->msgType; |
|
89 | + } |
|
86 | 90 | $result = $this->postHttp($this->config->get('webhook'), $data, true); |
87 | - if ($result['errcode'] == 0) return true; |
|
91 | + if ($result['errcode'] == 0) { |
|
92 | + return true; |
|
93 | + } |
|
88 | 94 | return false; |
89 | 95 | } else if (!empty($this->config->get('key'))) { |
90 | - if (empty($data['msgtype'])) $data['msgtype'] = $this->msgType; |
|
96 | + if (empty($data['msgtype'])) { |
|
97 | + $data['msgtype'] = $this->msgType; |
|
98 | + } |
|
91 | 99 | $result = $this->postHttp("{$this->apiUrl}cgi-bin/webhook/send?key=" . $this->config->get('key'), $data, true); |
92 | - if ($result['errcode'] == 0) return true; |
|
100 | + if ($result['errcode'] == 0) { |
|
101 | + return true; |
|
102 | + } |
|
93 | 103 | return false; |
94 | 104 | } else { |
95 | 105 | throw new QyWeXinException('企业微信自定义机器人接口未配置,【webhook,key】请配置其中一个'); |
@@ -120,7 +130,9 @@ discard block |
||
120 | 130 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
121 | 131 | $content = curl_exec($ch); |
122 | 132 | curl_close($ch); |
123 | - if (empty($is_json)) return $content; |
|
133 | + if (empty($is_json)) { |
|
134 | + return $content; |
|
135 | + } |
|
124 | 136 | try { |
125 | 137 | return json_decode($content, true); |
126 | 138 | } catch (\Exception $e) { |
@@ -73,7 +73,9 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function merge(array $data, $append = false) |
75 | 75 | { |
76 | - if ($append) return $this->config = array_merge($this->config, $data); |
|
76 | + if ($append) { |
|
77 | + return $this->config = array_merge($this->config, $data); |
|
78 | + } |
|
77 | 79 | return array_merge($this->config, $data); |
78 | 80 | } |
79 | 81 | |
@@ -84,7 +86,9 @@ discard block |
||
84 | 86 | */ |
85 | 87 | public function offsetSet($offset, $value) |
86 | 88 | { |
87 | - if (is_null($offset)) $this->config[] = $value; |
|
89 | + if (is_null($offset)) { |
|
90 | + $this->config[] = $value; |
|
91 | + } |
|
88 | 92 | $this->config[$offset] = $value; |
89 | 93 | } |
90 | 94 | |
@@ -104,7 +108,9 @@ discard block |
||
104 | 108 | */ |
105 | 109 | public function offsetUnset($offset = null) |
106 | 110 | { |
107 | - if (is_null($offset)) $this->config = []; |
|
111 | + if (is_null($offset)) { |
|
112 | + $this->config = []; |
|
113 | + } |
|
108 | 114 | unset($this->config[$offset]); |
109 | 115 | } |
110 | 116 | |
@@ -115,7 +121,9 @@ discard block |
||
115 | 121 | */ |
116 | 122 | public function offsetGet($offset = null) |
117 | 123 | { |
118 | - if (is_null($offset)) return $this->config; |
|
124 | + if (is_null($offset)) { |
|
125 | + return $this->config; |
|
126 | + } |
|
119 | 127 | return isset($this->config[$offset]) ? $this->config[$offset] : null; |
120 | 128 | } |
121 | 129 | } |