Passed
Push — master ( ffbf7e...4ee940 )
by ma
01:42
created
src/Gateways/Douyin.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -21,21 +21,21 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Douyin extends Gateway
23 23
 {
24
-    protected $ApiBase            = 'https://open.douyin.com';
24
+    protected $ApiBase = 'https://open.douyin.com';
25 25
     protected $AuthorizeURL   = 'https://open.douyin.com/platform/oauth/connect/';
26
-    protected $AuthorizeSilenceURL   = 'https://open.douyin.com/oauth/authorize/v2/';//抖音静默授权
26
+    protected $AuthorizeSilenceURL = 'https://open.douyin.com/oauth/authorize/v2/'; //抖音静默授权
27 27
     protected $AccessTokenURL = 'oauth/access_token/';
28 28
     protected $UserInfoURL = 'oauth/userinfo/';
29 29
 
30 30
     protected $jsCode2Session = 'https://minigame.zijieapi.com/mgplatform/api/apps/jscode2session';
31 31
 
32 32
     protected $API_BASE_ARRAY = [
33
-        'douyin'=>'https://open.douyin.com/',//抖音
34
-        'toutiao'=>'https://open.snssdk.com/',//头条
35
-        'xigua'=>'https://open-api.ixigua.com/',//西瓜
33
+        'douyin'=>'https://open.douyin.com/', //抖音
34
+        'toutiao'=>'https://open.snssdk.com/', //头条
35
+        'xigua'=>'https://open-api.ixigua.com/', //西瓜
36 36
     ];
37 37
 
38
-    public $oauth_type = ConstCode::TYPE_DOUYIN;//抖音
38
+    public $oauth_type = ConstCode::TYPE_DOUYIN; //抖音
39 39
 
40 40
     /**
41 41
      * Description:  得到跳转地址
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
             'redirect_uri'  => $this->config['callback'],
56 56
             'response_type' => $this->config['response_type'],
57 57
             'scope'         => $this->config['scope'],
58
-            'optionalScope' => $this->config['optionalScope']??'',
58
+            'optionalScope' => $this->config['optionalScope'] ?? '',
59 59
             'state'         => $this->config['state'],
60 60
         ];
61
-        if($params['state'] == 'login_id'){
61
+        if ($params['state'] == 'login_id') {
62 62
             /**
63 63
              * 抖音静默获取授权码
64 64
              * https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/account-permission/douyin-default-get-permission-code
65 65
              */
66
-            return $this->AuthorizeSilenceURL . '?' . http_build_query($params);
67
-        }else{
68
-            return $this->AuthorizeURL . '?' . http_build_query($params);
66
+            return $this->AuthorizeSilenceURL.'?'.http_build_query($params);
67
+        } else {
68
+            return $this->AuthorizeURL.'?'.http_build_query($params);
69 69
         }
70 70
     }
71 71
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
             'access_token'=> $this->token['access_token'] ?? '',
107 107
             'union_id'=> $this->token['unionid'] ?? '',
108 108
             'channel' => $this->oauth_type,
109
-            'nickname'=> $result['nickname']??'',
109
+            'nickname'=> $result['nickname'] ?? '',
110 110
             'gender'  => $result['gender'] ?? ConstCode::GENDER,
111
-            'avatar'  => $result['avatar']??'',
111
+            'avatar'  => $result['avatar'] ?? '',
112 112
         ];
113
-        $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'],$this->type);
113
+        $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'], $this->type);
114 114
         return $userInfo;
115 115
     }
116 116
 
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function getUserInfo()
125 125
     {
126
-        if($this->type == 'app'){//App登录
127
-            if(!isset($_REQUEST['access_token']) ){
126
+        if ($this->type == 'app') {//App登录
127
+            if (!isset($_REQUEST['access_token'])) {
128 128
                 throw new \Exception("Douyin APP登录 需要传输access_token参数! ");
129 129
             }
130 130
             $this->token['access_token'] = $_REQUEST['access_token'];
131
-        }elseif ($this->type == 'applets'){
131
+        }elseif ($this->type == 'applets') {
132 132
             //小程序
133 133
             return $this->applets();
134
-        }else {
134
+        } else {
135 135
             /** 获取token信息 */
136 136
             $this->getToken();
137 137
         }
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
      * @return array|mixed|null
151 151
      * @throws \Exception
152 152
      */
153
-    public function applets(){
153
+    public function applets() {
154 154
         /** 获取参数 */
155 155
         $params = $this->jscode2sessionParams();
156 156
 
157 157
         /** 获取access_token */
158
-        $token =  $this->get($this->jsCode2Session, $params);
158
+        $token = $this->get($this->jsCode2Session, $params);
159 159
         /** 解析token值(子类实现此方法) */
160 160
         $this->token = $this->parseToken($token);
161 161
         return $this->token;
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
      */
169 169
     private function switchAccessTokenURL()
170 170
     {
171
-        switch ($this->oauth_type){
172
-            case ConstCode::TYPE_DOUYIN:$this->ApiBase = $this->API_BASE_ARRAY['douyin'];break;
173
-            case ConstCode::TYPE_TOUTIAO:$this->ApiBase = $this->API_BASE_ARRAY['toutiao'];break;
174
-            case ConstCode::TYPE_XIGUA:$this->ApiBase = $this->API_BASE_ARRAY['xigua'];break;
171
+        switch ($this->oauth_type) {
172
+            case ConstCode::TYPE_DOUYIN:$this->ApiBase = $this->API_BASE_ARRAY['douyin']; break;
173
+            case ConstCode::TYPE_TOUTIAO:$this->ApiBase = $this->API_BASE_ARRAY['toutiao']; break;
174
+            case ConstCode::TYPE_XIGUA:$this->ApiBase = $this->API_BASE_ARRAY['xigua']; break;
175 175
             default:throw new \Exception("获取抖音 OAUTH_TYPE 参数出错:{$this->oauth_type}");
176 176
         }
177 177
         $this->AccessTokenURL = $this->ApiBase.$this->AccessTokenURL;
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
             'appid'      => $this->config['app_id'],
209 209
             'secret'     => $this->config['app_secret'],
210 210
         ];
211
-        if(isset($_REQUEST['code'])) $params['code'] = $_REQUEST['code'];
212
-        if(isset($_REQUEST['anonymous_code'])) $params['anonymous_code'] = $_REQUEST['anonymous_code'];
211
+        if (isset($_REQUEST['code'])) $params['code'] = $_REQUEST['code'];
212
+        if (isset($_REQUEST['anonymous_code'])) $params['anonymous_code'] = $_REQUEST['anonymous_code'];
213 213
 
214 214
         return $params;
215 215
     }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         $data = json_decode($token, true);
228 228
         if (isset($data['data']['access_token'])) {
229 229
             return $data['data'];
230
-        }elseif (isset($data['session_key'])){
230
+        }elseif (isset($data['session_key'])) {
231 231
             //小程序登录
232 232
             return $data;
233 233
         } else {
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
     /**
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
             'union_id'=> $this->token['unionid'] ?? '',
110 110
             'access_token'=> $this->token['access_token'] ?? '',
111 111
             'channel' => ConstCode::TYPE_WECHAT,
112
-            'nickname'=> $result['nickname']??'',
112
+            'nickname'=> $result['nickname'] ?? '',
113 113
             'gender'  => $result['sex'] ?? ConstCode::GENDER,
114
-            'avatar'  => $result['headimgurl']??'',
115
-            'session_key'  => $result['session_key']??'',
114
+            'avatar'  => $result['headimgurl'] ?? '',
115
+            'session_key'  => $result['session_key'] ?? '',
116 116
         ];
117
-        $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'],$this->type);
117
+        $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'], $this->type);
118 118
         return $userInfo;
119 119
     }
120 120
 
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function getUserInfo()
129 129
     {
130
-        if($this->type == 'app'){//App登录
131
-            if(!isset($_REQUEST['access_token']) ){
130
+        if ($this->type == 'app') {//App登录
131
+            if (!isset($_REQUEST['access_token'])) {
132 132
                 throw new \Exception("Wechat APP登录 需要传输access_token参数! ");
133 133
             }
134 134
             $this->token['access_token'] = $_REQUEST['access_token'];
135
-        }elseif ($this->type == 'applets'){
135
+        }elseif ($this->type == 'applets') {
136 136
             //小程序
137 137
             return $this->applets();
138
-        }else {
138
+        } else {
139 139
             /** 获取token信息 */
140 140
             $this->getToken();
141 141
         }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             'openid'=>$this->openid(),
147 147
             'lang'=>'zh_CN',
148 148
         ];
149
-        $data = $this->get(self::API_BASE . 'userinfo', $params);
149
+        $data = $this->get(self::API_BASE.'userinfo', $params);
150 150
         return json_decode($data, true);
151 151
     }
152 152
 
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
      * @return array|mixed|null
155 155
      * @throws \Exception
156 156
      */
157
-    public function applets(){
157
+    public function applets() {
158 158
         /** 获取参数 */
159 159
         $params = $this->accessTokenParams();
160 160
         $params['js_code'] = $params['code'];
161 161
 
162 162
         /** 获取access_token */
163
-        $token =  $this->get($this->jsCode2Session, $params);
163
+        $token = $this->get($this->jsCode2Session, $params);
164 164
         /** 解析token值(子类实现此方法) */
165 165
         $this->token = $this->parseToken($token);
166 166
         return $this->token;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         $data = json_decode($token, true);
217 217
         if (isset($data['access_token'])) {
218 218
             return $data;
219
-        }elseif (isset($data['session_key'])){
219
+        }elseif (isset($data['session_key'])) {
220 220
             //小程序登录
221 221
             return $data;
222 222
         } else {
Please login to merge, or discard this patch.
src/Gateways/Aliyun.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             'state'         => $this->config['state'],
40 40
             'scope'         => $this->config['scope'],
41 41
         ];
42
-        return $this->AuthorizeURL . '?' . http_build_query($params);
42
+        return $this->AuthorizeURL.'?'.http_build_query($params);
43 43
     }
44 44
 
45 45
     /**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $this->openid();
80 80
 
81 81
         $headers = ['Authorization: Bearer '.$this->token['access_token']];
82
-        $data = $this->get($this->UserInfoURL, [],$headers);
82
+        $data = $this->get($this->UserInfoURL, [], $headers);
83 83
         return json_decode($data, true);
84 84
     }
85 85
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @author: JiaMeng <[email protected]>
102 102
      * Updater:
103 103
      */
104
-    protected function getToken(){
104
+    protected function getToken() {
105 105
         if (empty($this->token)) {
106 106
             /** 验证state参数 */
107 107
             $this->CheckState();
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
             $params = $this->accessTokenParams();
111 111
 
112 112
             /** 获取access_token */
113
-            $this->AccessTokenURL = $this->AccessTokenURL . '?' . http_build_query($params);
114
-            $token =  $this->post($this->AccessTokenURL);
113
+            $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params);
114
+            $token = $this->post($this->AccessTokenURL);
115 115
             /** 解析token值(子类实现此方法) */
116 116
             $this->token = $this->parseToken($token);
117 117
         }
Please login to merge, or discard this patch.
src/Helper/ConstCode.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@  discard block
 block discarded – undo
6 6
 
7 7
 use tinymeng\tools\Tool;
8 8
 
9
-class ConstCode{
9
+class ConstCode {
10 10
 
11 11
     /** 公共状态 */
12
-    const STATUS_DELETE = 0;//删除
13
-    const STATUS_NORMAL = 1;//正常
12
+    const STATUS_DELETE = 0; //删除
13
+    const STATUS_NORMAL = 1; //正常
14 14
 
15 15
     /** 性别 */
16
-    const GENDER = 0;//未知
17
-    const GENDER_MAN = 1;//男
18
-    const GENDER_WOMEN = 2;//女
16
+    const GENDER = 0; //未知
17
+    const GENDER_MAN = 1; //男
18
+    const GENDER_WOMEN = 2; //女
19 19
 
20 20
     /** 登录类型 */
21 21
     const TYPE_QQ               = 1; //QQ
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
     const TYPE_FACEBOOK         = 7; //faceBook
28 28
     const TYPE_GOOGLE           = 8; //google
29 29
     const TYPE_TWITTER          = 9; //飞鸽
30
-    const TYPE_LINE             = 10;//line
31
-    const TYPE_NAVER             = 11;//naver
30
+    const TYPE_LINE             = 10; //line
31
+    const TYPE_NAVER = 11; //naver
32 32
     const TYPE_ALIYUN           = 12; //阿里云
33 33
 
34 34
     const TYPE_QQ_APP           = 21; //qqAPP
@@ -47,24 +47,24 @@  discard block
 block discarded – undo
47 47
      * @param bool $type 类型:app applets
48 48
      * @return int
49 49
      */
50
-    static public function getTypeConst($channel,$type="")
50
+    static public function getTypeConst($channel, $type = "")
51 51
     {
52
-        switch ($channel){
52
+        switch ($channel) {
53 53
             case self::TYPE_QQ:
54
-                if($type == 'app'){
55
-                    $typeConst = self::TYPE_QQ_APP;//qqApp
56
-                }else{
54
+                if ($type == 'app') {
55
+                    $typeConst = self::TYPE_QQ_APP; //qqApp
56
+                } else {
57 57
                     $typeConst = $channel;
58 58
                 }
59 59
                 break;
60 60
             case self::TYPE_WECHAT:
61
-                if($type == 'app'){
62
-                    $typeConst = self::TYPE_WECHAT_APP;//微信App
63
-                }else if($type == 'applets'){
64
-                    $typeConst =  self::TYPE_WECHAT_APPLETS;//微信小程序
65
-                }else if(Tool::isWeiXin()){
66
-                    $typeConst =  self::TYPE_WECHAT_MOBILE;//微信mobile
67
-                }else{
61
+                if ($type == 'app') {
62
+                    $typeConst = self::TYPE_WECHAT_APP; //微信App
63
+                } else if ($type == 'applets') {
64
+                    $typeConst = self::TYPE_WECHAT_APPLETS; //微信小程序
65
+                } else if (Tool::isWeiXin()) {
66
+                    $typeConst = self::TYPE_WECHAT_MOBILE; //微信mobile
67
+                } else {
68 68
                     $typeConst = $channel;
69 69
                 }
70 70
                 break;
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
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             'nickname'=> $result['nickname'],
64 64
             'gender'  => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER,
65 65
             'avatar'  => $result['figureurl_qq_2'] ? $result['figureurl_qq_2'] : $result['figureurl_qq_1'],
66
-            'birthday'=> date('Y-m-d',strtotime($result['year'])),
66
+            'birthday'=> date('Y-m-d', strtotime($result['year'])),
67 67
         ];
68 68
         return $userInfo;
69 69
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             'access_token'=>$this->token['access_token'],
85 85
             'format'=>'json',
86 86
         ];
87
-        $data = $this->get(self::API_BASE . 'user/get_user_info', $params);
87
+        $data = $this->get(self::API_BASE.'user/get_user_info', $params);
88 88
         return json_decode($data, true);
89 89
     }
90 90
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function openid()
99 99
     {
100
-        if($this->type == 'app'){//App登录
101
-            if(!isset($_REQUEST['access_token'])){
100
+        if ($this->type == 'app') {//App登录
101
+            if (!isset($_REQUEST['access_token'])) {
102 102
                 throw new \Exception("腾讯QQ,APP登录 需要传输access_token参数! ");
103 103
             }
104 104
             $this->token['access_token'] = $_REQUEST['access_token'];
105
-        }else{
105
+        } else {
106 106
             /** 获取token */
107 107
             $this->getToken();
108 108
         }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         if (isset($data['access_token'])) {
129 129
             return $data;
130 130
         } else {
131
-            throw new \Exception("获取腾讯QQ ACCESS_TOKEN 出错:" . $token);
131
+            throw new \Exception("获取腾讯QQ ACCESS_TOKEN 出错:".$token);
132 132
         }
133 133
     }
134 134
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @return mixed|string
140 140
      * @throws \Exception
141 141
      */
142
-    private function getOpenID(){
142
+    private function getOpenID() {
143 143
         $query = [
144 144
             'access_token' => $this->token['access_token']
145 145
         ];
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
             $query['unionid'] = 1;
149 149
         }
150 150
 
151
-        $data = $this->get(self::API_BASE . 'oauth2.0/me',$query);
152
-        $data     = json_decode(trim(substr($data, 9), " );\n"), true);
151
+        $data = $this->get(self::API_BASE.'oauth2.0/me', $query);
152
+        $data = json_decode(trim(substr($data, 9), " );\n"), true);
153 153
         if (isset($data['openid'])) {
154 154
             return $data;
155 155
         } else {
156
-            throw new \Exception("获取用户openid出错:" . $data['error_description']);
156
+            throw new \Exception("获取用户openid出错:".$data['error_description']);
157 157
         }
158 158
     }
159 159
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      * M代表男性,F代表女性
163 163
      * @param $gender
164 164
      */
165
-    public function getGender($gender){
165
+    public function getGender($gender) {
166 166
         return $gender == '男' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN;
167 167
     }
168 168
 
Please login to merge, or discard this patch.
src/Gateways/Alipay.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             $this->AuthorizeURL = str_replace("alipay", "alipaydev", $this->AuthorizeURL);
73 73
         }
74 74
 
75
-        return $this->AuthorizeURL . '?' . http_build_query($params);
75
+        return $this->AuthorizeURL.'?'.http_build_query($params);
76 76
     }
77 77
 
78 78
     /**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             'gender'  => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER,
113 113
             'avatar'  => $result['avatar'],
114 114
         ];
115
-        $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'],$this->type);
115
+        $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'], $this->type);
116 116
         return $userInfo;
117 117
     }
118 118
 
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function getUserInfo()
127 127
     {
128
-        if($this->type == 'app'){//App登录
129
-            if(!isset($_REQUEST['access_token']) ){
128
+        if ($this->type == 'app') {//App登录
129
+            if (!isset($_REQUEST['access_token'])) {
130 130
                 throw new \Exception("AliPay APP登录 需要传输access_token参数! ");
131 131
             }
132 132
             $this->token['access_token'] = $_REQUEST['access_token'];
133
-        }else {
133
+        } else {
134 134
             /** 获取token信息 */
135 135
             $this->getToken();
136 136
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
         $data = $this->post(self::API_BASE, $params);
150 150
         $data = mb_convert_encoding($data, 'utf-8', 'gbk');
151
-        $result =  json_decode($data, true);
151
+        $result = json_decode($data, true);
152 152
         return $result['alipay_user_info_share_response'];
153 153
     }
154 154
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             throw new \Exception('支付宝RSA密钥未配置');
226 226
         }
227 227
         $rsa    = str_replace([PHP_EOL, $header, $footer], '', $rsa);
228
-        $rsaVal = $header . PHP_EOL . chunk_split($rsa, 64, PHP_EOL) . $footer;
228
+        $rsaVal = $header.PHP_EOL.chunk_split($rsa, 64, PHP_EOL).$footer;
229 229
         return $rsaVal;
230 230
     }
231 231
 
Please login to merge, or discard this patch.
src/Connector/Gateway.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         if (!$config) {
92 92
             throw new \Exception('传入的配置不能为空');
93 93
         }
94
-        if(isset($_GET['referer']) && $config['callback']){
94
+        if (isset($_GET['referer']) && $config['callback']) {
95 95
             $config['callback'] .= ((strpos($config['callback'], '?') !== false) ? '&' : '?').'referer='.$_GET['referer'];
96 96
         }
97 97
         //默认参数
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
             'proxy'         => '',
105 105
             'state'         => '',
106 106
             'type'          => '',
107
-            'is_sandbox'    => false,//是否是沙箱环境
107
+            'is_sandbox'    => false, //是否是沙箱环境
108 108
         ];
109
-        $this->config    = array_merge($_config, $config);
110
-        foreach($this->config as $key=>$val){
111
-            if(property_exists($this,$key)) $this->$key=$val;
109
+        $this->config = array_merge($_config, $config);
110
+        foreach ($this->config as $key=>$val) {
111
+            if (property_exists($this, $key)) $this->$key = $val;
112 112
         }
113 113
         $this->timestamp = time();
114 114
     }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      * Updater:
145 145
      * @return $this
146 146
      */
147
-    public function mustCheckState(){
147
+    public function mustCheckState() {
148 148
         $this->checkState = true;
149 149
         return $this;
150 150
     }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      * @Author: TinyMeng <[email protected]>
155 155
      * @return array
156 156
      */
157
-    public function getConfig(){
157
+    public function getConfig() {
158 158
         return $this->config;
159 159
     }
160 160
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * @param $token
164 164
      * @return $this
165 165
      */
166
-    public function setToken($token){
166
+    public function setToken($token) {
167 167
         $this->token = $token;
168 168
         return $this;
169 169
     }
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
      * 存储state
173 173
      * @Author: TinyMeng <[email protected]>
174 174
      */
175
-    public function saveState(){
175
+    public function saveState() {
176 176
         if ($this->checkState === true) {
177 177
             //是否开启session
178 178
             if (session_status() !== PHP_SESSION_ACTIVE) {
179 179
                 session_start();
180 180
             }
181
-            if(empty($this->config['state'])){
182
-                $this->config['state'] = Str::random();//生成随机state
181
+            if (empty($this->config['state'])) {
182
+                $this->config['state'] = Str::random(); //生成随机state
183 183
             }
184 184
             //存储到session
185 185
             $_SESSION['tinymeng_oauth_state'] = $this->config['state'];
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @Author: TinyMeng <[email protected]>
192 192
      * @throws \Exception
193 193
      */
194
-    public function checkState(){
194
+    public function checkState() {
195 195
         if ($this->checkState === true) {
196 196
             if (session_status() !== PHP_SESSION_ACTIVE) {
197 197
                 session_start();
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      * @author: JiaMeng <[email protected]>
209 209
      * @return string
210 210
      */
211
-    public function getCode(){
211
+    public function getCode() {
212 212
         return isset($_REQUEST['code']) ? $_REQUEST['code'] : '';
213 213
     }
214 214
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * Updater:
219 219
      * @return array
220 220
      */
221
-    protected function accessTokenParams(){
221
+    protected function accessTokenParams() {
222 222
         $params = [
223 223
             'client_id'     => $this->config['app_id'],
224 224
             'client_secret' => $this->config['app_secret'],
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      * @author: JiaMeng <[email protected]>
235 235
      * Updater:
236 236
      */
237
-    protected function getToken(){
237
+    protected function getToken() {
238 238
         if (empty($this->token)) {
239 239
             /** 验证state参数 */
240 240
             $this->checkState();
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
             $params = $this->accessTokenParams();
244 244
 
245 245
             /** 获取access_token */
246
-            $token =  $this->POST($this->AccessTokenURL, $params);
246
+            $token = $this->POST($this->AccessTokenURL, $params);
247 247
             /** 解析token值(子类实现此方法) */
248 248
             $this->token = $this->parseToken($token);
249
-        }else{
249
+        } else {
250 250
             return $this->token;
251 251
         }
252 252
     }
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      */
263 263
     protected function get($url, $params = [], $headers = [])
264 264
     {
265
-        return \tinymeng\tools\HttpRequest::httpGet($url, $params,$headers);
265
+        return \tinymeng\tools\HttpRequest::httpGet($url, $params, $headers);
266 266
     }
267 267
 
268 268
     /**
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
      */
277 277
     protected function post($url, $params = [], $headers = [])
278 278
     {
279
-        $headers[] = 'Accept: application/json';//GitHub需要的header
280
-        return \tinymeng\tools\HttpRequest::httpPost($url, $params,$headers);
279
+        $headers[] = 'Accept: application/json'; //GitHub需要的header
280
+        return \tinymeng\tools\HttpRequest::httpPost($url, $params, $headers);
281 281
     }
282 282
 
283 283
     /**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
      * M代表男性,F代表女性
286 286
      * @param $gender
287 287
      */
288
-    public function getGender($gender){
289
-        return strtolower(substr($gender , 0 , 1)) == 'm' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN;
288
+    public function getGender($gender) {
289
+        return strtolower(substr($gender, 0, 1)) == 'm' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN;
290 290
     }
291 291
 
292 292
 
Please login to merge, or discard this patch.