Passed
Push — master ( 8d60a4...d4e015 )
by ma
02:18 queued 14s
created
src/Gateways/Github.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
             'scope'        => $this->config['scope'],
41 41
             'state'        => $this->config['state'],
42 42
             'display'      => $this->display,
43
-            'allow_signup' => true,//是否会在OAuth流程中为未经身份验证的用户提供注册GitHub的选项。默认是true。false在策略禁止注册的情况下使用。
43
+            'allow_signup' => true, //是否会在OAuth流程中为未经身份验证的用户提供注册GitHub的选项。默认是true。false在策略禁止注册的情况下使用。
44 44
         ];
45
-        return $this->AuthorizeURL . '?' . http_build_query($params);
45
+        return $this->AuthorizeURL.'?'.http_build_query($params);
46 46
     }
47 47
 
48 48
     /**
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
     {
99 99
         $this->getToken();
100 100
 
101
-        $url = self::API_BASE . "user";
101
+        $url = self::API_BASE."user";
102 102
         $headers = [
103 103
             'User-Agent: '.$this->config['application_name'],
104 104
             'UserModel-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 ',
105
-            'Authorization: token ' . $this->token['access_token'],
105
+            'Authorization: token '.$this->token['access_token'],
106 106
             'Accept: application/json'
107 107
         ];
108 108
         $response = $this->get($url, [], $headers);
Please login to merge, or discard this patch.
src/Gateways/Google.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             'scope'         => $this->config['scope'],
41 41
             'state'         => $this->config['state'],
42 42
         ];
43
-        return self::AUTHORIZE_URL . '?' . http_build_query($params);
43
+        return self::AUTHORIZE_URL.'?'.http_build_query($params);
44 44
     }
45 45
 
46 46
     /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             'gender'  => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER,
68 68
             'avatar'  => $result['picture'],
69 69
         ];
70
-        if(isset($result['email'])){
70
+        if (isset($result['email'])) {
71 71
             $userInfo['email'] = $result['email'];
72 72
         }
73 73
         return $userInfo;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function getUserInfo()
80 80
     {
81
-        if($this->type == 'app'){//App登录
82
-            if(!isset($_REQUEST['code']) ){
81
+        if ($this->type == 'app') {//App登录
82
+            if (!isset($_REQUEST['code'])) {
83 83
                 throw new \Exception("Google APP登录 需要传输code参数! ");
84 84
             }
85 85
         }
86 86
         $this->getToken();
87
-        $headers = ['Authorization : Bearer ' . $this->token['access_token']];
88
-        $data = $this->get(self::API_BASE . 'oauth2/v2/userinfo', '', $headers);
87
+        $headers = ['Authorization : Bearer '.$this->token['access_token']];
88
+        $data = $this->get(self::API_BASE.'oauth2/v2/userinfo', '', $headers);
89 89
         return json_decode($data, true);
90 90
     }
91 91
 
Please login to merge, or discard this patch.
src/Gateways/Facebook.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             'scope'         => $this->config['scope'],
44 44
             'state'         => $this->config['state'] ?: Str::random(),
45 45
         ];
46
-        return $this->AuthorizeURL . '?' . http_build_query($params);
46
+        return $this->AuthorizeURL.'?'.http_build_query($params);
47 47
     }
48 48
 
49 49
     /**
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function getUserInfo()
79 79
     {
80
-        if($this->type == 'app'){//App登录
81
-            if(!isset($_REQUEST['access_token']) ){
80
+        if ($this->type == 'app') {//App登录
81
+            if (!isset($_REQUEST['access_token'])) {
82 82
                 throw new \Exception("Facebook APP登录 需要传输access_token参数! ");
83 83
             }
84 84
             $this->token['access_token'] = $_REQUEST['access_token'];
85
-        }else {
85
+        } else {
86 86
             $this->getToken();
87 87
         }
88 88
         $fields = isset($this->config['fields']) ? $this->config['fields'] : 'id,name,gender,picture.width(400)';
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $method  = strtoupper($method);
103 103
         $request = [
104 104
             'method' => $method,
105
-            'uri'    => self::API_BASE . $api,
105
+            'uri'    => self::API_BASE.$api,
106 106
         ];
107 107
 
108 108
         $data = $this->$method($request['uri'], $params);
Please login to merge, or discard this patch.
src/Gateways/Qq.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
             'scope'         => $this->config['scope'],
42 42
             'display'       => $this->display,
43 43
         ];
44
-        return $this->AuthorizeURL . '?' . http_build_query($params);
44
+        return $this->AuthorizeURL.'?'.http_build_query($params);
45 45
     }
46 46
 
47 47
     /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             'nickname'=> $result['nickname'],
63 63
             'gender'  => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER,
64 64
             'avatar'  => $result['figureurl_qq_2'] ? $result['figureurl_qq_2'] : $result['figureurl_qq_1'],
65
-            'birthday'=> date('Y-m-d',strtotime($result['year'])),
65
+            'birthday'=> date('Y-m-d', strtotime($result['year'])),
66 66
         ];
67 67
         return $userInfo;
68 68
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             'access_token'=>$this->token['access_token'],
84 84
             'format'=>'json',
85 85
         ];
86
-        $data = $this->get(self::API_BASE . 'user/get_user_info', $params);
86
+        $data = $this->get(self::API_BASE.'user/get_user_info', $params);
87 87
         return json_decode($data, true);
88 88
     }
89 89
 
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function openid()
98 98
     {
99
-        if($this->type == 'app'){//App登录
100
-            if(!isset($_REQUEST['access_token'])){
99
+        if ($this->type == 'app') {//App登录
100
+            if (!isset($_REQUEST['access_token'])) {
101 101
                 throw new \Exception("腾讯QQ,APP登录 需要传输access_token参数! ");
102 102
             }
103 103
             $this->token['access_token'] = $_REQUEST['access_token'];
104
-        }else{
104
+        } else {
105 105
             /** 获取token */
106 106
             $this->getToken();
107 107
         }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         if (isset($data['access_token'])) {
128 128
             return $data;
129 129
         } else {
130
-            throw new \Exception("获取腾讯QQ ACCESS_TOKEN 出错:" . $token);
130
+            throw new \Exception("获取腾讯QQ ACCESS_TOKEN 出错:".$token);
131 131
         }
132 132
     }
133 133
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @return mixed|string
139 139
      * @throws \Exception
140 140
      */
141
-    private function getOpenID(){
141
+    private function getOpenID() {
142 142
         $query = [
143 143
             'access_token' => $this->token['access_token']
144 144
         ];
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
             $query['unionid'] = 1;
148 148
         }
149 149
 
150
-        $data = $this->get(self::API_BASE . 'oauth2.0/me',$query);
151
-        $data     = json_decode(trim(substr($data, 9), " );\n"), true);
150
+        $data = $this->get(self::API_BASE.'oauth2.0/me', $query);
151
+        $data = json_decode(trim(substr($data, 9), " );\n"), true);
152 152
         if (isset($data['openid'])) {
153 153
             return $data;
154 154
         } else {
155
-            throw new \Exception("获取用户openid出错:" . $data['error_description']);
155
+            throw new \Exception("获取用户openid出错:".$data['error_description']);
156 156
         }
157 157
     }
158 158
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      * M代表男性,F代表女性
162 162
      * @param $gender
163 163
      */
164
-    public function getGender($gender){
164
+    public function getGender($gender) {
165 165
         return $gender == '男' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN;
166 166
     }
167 167
 }
Please login to merge, or discard this patch.
src/Gateways/Naver.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             'scope'         => $this->config['scope'],
39 39
             'state'         => $this->config['state'] ?: Str::random(),
40 40
         ];
41
-        return $this->AuthorizeURL . '?' . http_build_query($params);
41
+        return $this->AuthorizeURL.'?'.http_build_query($params);
42 42
     }
43 43
 
44 44
     /**
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function getUserInfo()
76 76
     {
77
-        if($this->type == 'app'){//App登录
78
-            if(!isset($_REQUEST['access_token']) ){
77
+        if ($this->type == 'app') {//App登录
78
+            if (!isset($_REQUEST['access_token'])) {
79 79
                 throw new \Exception("Naver APP登录 需要传输access_token参数! ");
80 80
             }
81 81
             $this->token['token_type'] = 'Bearer';
82 82
             $this->token['access_token'] = $_REQUEST['access_token'];
83
-        }else {
83
+        } else {
84 84
             $this->getToken();
85 85
         }
86 86
         $data = $this->call('nid/me', $this->token, 'GET');
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
         $method  = strtoupper($method);
104 104
         $request = [
105 105
             'method' => $method,
106
-            'uri'    => self::API_BASE . $api,
106
+            'uri'    => self::API_BASE.$api,
107 107
         ];
108 108
 
109
-        $headers = ['Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']];
109
+        $headers = ['Authorization' => $this->token['token_type'].' '.$this->token['access_token']];
110 110
 
111 111
         $data = $this->$method($request['uri'], $params, $headers);
112 112
 
Please login to merge, or discard this patch.
src/Gateways/Sina.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             'state'        => $this->config['state'],
38 38
             'display'      => $this->display,
39 39
         ];
40
-        return $this->AuthorizeURL . '?' . http_build_query($params);
40
+        return $this->AuthorizeURL.'?'.http_build_query($params);
41 41
     }
42 42
 
43 43
     /**
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function getUserInfo()
90 90
     {
91
-        if($this->type == 'app'){//App登录
92
-            if(!isset($_REQUEST['access_token']) || !isset($_REQUEST['uid'])){
91
+        if ($this->type == 'app') {//App登录
92
+            if (!isset($_REQUEST['access_token']) || !isset($_REQUEST['uid'])) {
93 93
                 throw new \Exception("Sina APP登录 需要传输access_token和uid参数! ");
94 94
             }
95 95
             $this->token['access_token'] = $_REQUEST['access_token'];
96 96
             $this->token['openid'] = $_REQUEST['uid'];
97
-        }else{
97
+        } else {
98 98
             /** 获取参数 */
99 99
             $params = $this->accessTokenParams();
100
-            $this->AccessTokenURL = $this->AccessTokenURL. '?' . http_build_query($params);//get传参
100
+            $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params); //get传参
101 101
             $this->getToken();
102 102
         }
103 103
 
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $method = strtoupper($method);
119 119
 
120
-        if(isset($this->token['access_token'])){
120
+        if (isset($this->token['access_token'])) {
121 121
             $params['access_token'] = $this->token['access_token'];
122 122
         }
123 123
 
124
-        $data = $this->$method(self::API_BASE . $api, $params);
124
+        $data = $this->$method(self::API_BASE.$api, $params);
125 125
         return json_decode($data, true);
126 126
     }
127 127
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
      * @param $data
163 163
      * @return mixed
164 164
      */
165
-    public function statusesShare($data){
166
-        return $this->call('statuses/share.json', json_encode($data),'POST');
165
+    public function statusesShare($data) {
166
+        return $this->call('statuses/share.json', json_encode($data), 'POST');
167 167
     }
168 168
 
169 169
 }
Please login to merge, or discard this patch.
src/Gateways/Wechat.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $this->saveState();
42 42
 
43 43
         //获取代理链接
44
-        if(isset($this->config['proxy_url'])){
44
+        if (isset($this->config['proxy_url'])) {
45 45
             return $this->getProxyURL();
46 46
         }
47 47
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             'scope'         => $this->config['scope'],
55 55
             'state'         => $this->config['state'],
56 56
         ];
57
-        return $this->AuthorizeURL . '?' . http_build_query($params) . '#wechat_redirect';
57
+        return $this->AuthorizeURL.'?'.http_build_query($params).'#wechat_redirect';
58 58
     }
59 59
 
60 60
     /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             'state'         => $this->config['state'],
73 73
             'redirect_uri'    => $this->config['callback'],
74 74
         ];
75
-        return $this->config['proxy_url'] . '?' . http_build_query($params);
75
+        return $this->config['proxy_url'].'?'.http_build_query($params);
76 76
     }
77 77
 
78 78
     /**
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
             'open_id' => $this->openid(),
109 109
             'union_id'=> isset($this->token['unionid']) ? $this->token['unionid'] : '',
110 110
             'channel' => ConstCode::TYPE_WECHAT,
111
-            'nickname'=> $result['nickname']??'',
111
+            'nickname'=> $result['nickname'] ?? '',
112 112
             'gender'  => isset($result['sex']) ? $result['sex'] : ConstCode::GENDER,
113
-            'avatar'  => $result['headimgurl']??'',
114
-            'session_key'  => $result['session_key']??'',
113
+            'avatar'  => $result['headimgurl'] ?? '',
114
+            'session_key'  => $result['session_key'] ?? '',
115 115
         ];
116
-        $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'],$this->type);
116
+        $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'], $this->type);
117 117
         return $userInfo;
118 118
     }
119 119
 
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function getUserInfo()
128 128
     {
129
-        if($this->type == 'app'){//App登录
130
-            if(!isset($_REQUEST['access_token']) ){
129
+        if ($this->type == 'app') {//App登录
130
+            if (!isset($_REQUEST['access_token'])) {
131 131
                 throw new \Exception("Wechat APP登录 需要传输access_token参数! ");
132 132
             }
133 133
             $this->token['access_token'] = $_REQUEST['access_token'];
134
-        }elseif ($this->type == 'applets'){
134
+        }elseif ($this->type == 'applets') {
135 135
             //小程序
136 136
             return $this->applets();
137
-        }else {
137
+        } else {
138 138
             /** 获取token信息 */
139 139
             $this->getToken();
140 140
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
             'openid'=>$this->openid(),
146 146
             'lang'=>'zh_CN',
147 147
         ];
148
-        $data = $this->get(self::API_BASE . 'userinfo', $params);
148
+        $data = $this->get(self::API_BASE.'userinfo', $params);
149 149
         return json_decode($data, true);
150 150
     }
151 151
 
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
      * @return array|mixed|null
154 154
      * @throws \Exception
155 155
      */
156
-    public function applets(){
156
+    public function applets() {
157 157
         /** 获取参数 */
158 158
         $params = $this->accessTokenParams();
159 159
         $params['js_code'] = $params['code'];
160 160
 
161 161
         /** 获取access_token */
162
-        $token =  $this->get($this->jsCode2Session, $params);
162
+        $token = $this->get($this->jsCode2Session, $params);
163 163
         /** 解析token值(子类实现此方法) */
164 164
         $this->token = $this->parseToken($token);
165 165
         return $this->token;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         $data = json_decode($token, true);
216 216
         if (isset($data['access_token'])) {
217 217
             return $data;
218
-        }elseif (isset($data['session_key'])){
218
+        }elseif (isset($data['session_key'])) {
219 219
             //小程序登录
220 220
             return $data;
221 221
         } else {
Please login to merge, or discard this patch.
src/Connector/Gateway.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
             'proxy'         => '',
96 96
             'state'         => '',
97 97
             'type'          => '',
98
-            'is_sandbox'    => false,//是否是沙箱环境
98
+            'is_sandbox'    => false, //是否是沙箱环境
99 99
         ];
100
-        $this->config    = array_merge($_config, $config);
101
-        foreach($this->config as $key=>$val){
102
-            if(property_exists($this,$key)) $this->$key=$val;
100
+        $this->config = array_merge($_config, $config);
101
+        foreach ($this->config as $key=>$val) {
102
+            if (property_exists($this, $key)) $this->$key = $val;
103 103
         }
104 104
         $this->timestamp = time();
105 105
     }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      * Updater:
136 136
      * @return $this
137 137
      */
138
-    public function mustCheckState(){
138
+    public function mustCheckState() {
139 139
         $this->checkState = true;
140 140
         return $this;
141 141
     }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      * @Author: TinyMeng <[email protected]>
146 146
      * @return array
147 147
      */
148
-    public function getConfig(){
148
+    public function getConfig() {
149 149
         return $this->config;
150 150
     }
151 151
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      * @param $token
155 155
      * @return $this
156 156
      */
157
-    public function setToken($token){
157
+    public function setToken($token) {
158 158
         $this->token = $token;
159 159
         return $this;
160 160
     }
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
      * 存储state
164 164
      * @Author: TinyMeng <[email protected]>
165 165
      */
166
-    public function saveState(){
166
+    public function saveState() {
167 167
         if ($this->checkState === true) {
168 168
             //是否开启session
169 169
             if (session_status() !== PHP_SESSION_ACTIVE) {
170 170
                 session_start();
171 171
             }
172
-            if(empty($this->config['state'])){
173
-                $this->config['state'] = Str::random();//生成随机state
172
+            if (empty($this->config['state'])) {
173
+                $this->config['state'] = Str::random(); //生成随机state
174 174
             }
175 175
             //存储到session
176 176
             $_SESSION['tinymeng_oauth_state'] = $this->config['state'];
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      * @Author: TinyMeng <[email protected]>
183 183
      * @throws \Exception
184 184
      */
185
-    public function CheckState(){
185
+    public function CheckState() {
186 186
         if ($this->checkState === true) {
187 187
             if (session_status() !== PHP_SESSION_ACTIVE) {
188 188
                 session_start();
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      * Updater:
200 200
      * @return array
201 201
      */
202
-    protected function accessTokenParams(){
202
+    protected function accessTokenParams() {
203 203
         $params = [
204 204
             'client_id'     => $this->config['app_id'],
205 205
             'client_secret' => $this->config['app_secret'],
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
      * @author: JiaMeng <[email protected]>
216 216
      * Updater:
217 217
      */
218
-    protected function getToken(){
218
+    protected function getToken() {
219 219
         if (empty($this->token)) {
220 220
             /** 验证state参数 */
221 221
             $this->CheckState();
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             $params = $this->accessTokenParams();
225 225
 
226 226
             /** 获取access_token */
227
-            $token =  $this->POST($this->AccessTokenURL, $params);
227
+            $token = $this->POST($this->AccessTokenURL, $params);
228 228
             /** 解析token值(子类实现此方法) */
229 229
             $this->token = $this->parseToken($token);
230 230
         }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     protected function get($url, $params = [], $headers = [])
243 243
     {
244
-        return \tinymeng\tools\HttpRequest::httpGet($url, $params,$headers);
244
+        return \tinymeng\tools\HttpRequest::httpGet($url, $params, $headers);
245 245
     }
246 246
 
247 247
     /**
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
      */
256 256
     protected function post($url, $params = [], $headers = [])
257 257
     {
258
-        $headers[] = 'Accept: application/json';//GitHub需要的header
259
-        return \tinymeng\tools\HttpRequest::httpPost($url, $params,$headers);
258
+        $headers[] = 'Accept: application/json'; //GitHub需要的header
259
+        return \tinymeng\tools\HttpRequest::httpPost($url, $params, $headers);
260 260
     }
261 261
 
262 262
     /**
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      * M代表男性,F代表女性
265 265
      * @param $gender
266 266
      */
267
-    public function getGender($gender){
268
-        return strtolower(substr($gender , 0 , 1)) == 'm' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN;
267
+    public function getGender($gender) {
268
+        return strtolower(substr($gender, 0, 1)) == 'm' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN;
269 269
     }
270 270
 }
Please login to merge, or discard this patch.
src/Helper/Str.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
             if (in_array($k, $except)) {
16 16
                 continue;
17 17
             }
18
-            $param_str .= $k . '=';
18
+            $param_str .= $k.'=';
19 19
             $param_str .= $urlencode ? rawurlencode($v) : $v;
20 20
             $param_str .= '&';
21 21
         }
Please login to merge, or discard this patch.