Passed
Push — master ( 7d7f87...8d60a4 )
by ma
01:36
created
src/Connector/Gateway.php 2 patches
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.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,9 @@
 block discarded – undo
99 99
         ];
100 100
         $this->config    = array_merge($_config, $config);
101 101
         foreach($this->config as $key=>$val){
102
-            if(property_exists($this,$key)) $this->$key=$val;
102
+            if(property_exists($this,$key)) {
103
+                $this->$key=$val;
104
+            }
103 105
         }
104 106
         $this->timestamp = time();
105 107
     }
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.
src/Helper/ConstCode.php 2 patches
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
 
33 33
     const TYPE_QQ_APP           = 21; //qqAPP
34 34
     const TYPE_WECHAT_APP       = 22; //微信APP
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
      * @param bool $type 类型:app applets
47 47
      * @return int
48 48
      */
49
-    static public function getTypeConst($channel,$type="")
49
+    static public function getTypeConst($channel, $type = "")
50 50
     {
51
-        switch ($channel){
51
+        switch ($channel) {
52 52
             case self::TYPE_QQ:
53
-                if($type == 'app'){
54
-                    $typeConst = self::TYPE_WECHAT_APP;//qqApp
55
-                }else{
53
+                if ($type == 'app') {
54
+                    $typeConst = self::TYPE_WECHAT_APP; //qqApp
55
+                } else {
56 56
                     $typeConst = $channel;
57 57
                 }
58 58
                 break;
59 59
             case self::TYPE_WECHAT:
60
-                if($type == 'app'){
61
-                    $typeConst = self::TYPE_WECHAT_APP;//微信App
62
-                }else if($type == 'applets'){
63
-                    $typeConst =  self::TYPE_WECHAT_APPLETS;//微信小程序
64
-                }else if(Tool::isWeiXin()){
65
-                    $typeConst =  self::TYPE_WECHAT_MOBILE;//微信mobile
66
-                }else{
60
+                if ($type == 'app') {
61
+                    $typeConst = self::TYPE_WECHAT_APP; //微信App
62
+                } else if ($type == 'applets') {
63
+                    $typeConst = self::TYPE_WECHAT_APPLETS; //微信小程序
64
+                } else if (Tool::isWeiXin()) {
65
+                    $typeConst = self::TYPE_WECHAT_MOBILE; //微信mobile
66
+                } else {
67 67
                     $typeConst = $channel;
68 68
                 }
69 69
                 break;
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,18 +52,18 @@
 block discarded – undo
52 52
             case self::TYPE_QQ:
53 53
                 if($type == 'app'){
54 54
                     $typeConst = self::TYPE_WECHAT_APP;//qqApp
55
-                }else{
55
+                } else{
56 56
                     $typeConst = $channel;
57 57
                 }
58 58
                 break;
59 59
             case self::TYPE_WECHAT:
60 60
                 if($type == 'app'){
61 61
                     $typeConst = self::TYPE_WECHAT_APP;//微信App
62
-                }else if($type == 'applets'){
62
+                } else if($type == 'applets'){
63 63
                     $typeConst =  self::TYPE_WECHAT_APPLETS;//微信小程序
64
-                }else if(Tool::isWeiXin()){
64
+                } else if(Tool::isWeiXin()){
65 65
                     $typeConst =  self::TYPE_WECHAT_MOBILE;//微信mobile
66
-                }else{
66
+                } else{
67 67
                     $typeConst = $channel;
68 68
                 }
69 69
                 break;
Please login to merge, or discard this patch.
src/Gateways/Line.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             'scope'         => $this->config['scope'],
34 34
             'state'         => $this->config['state'] ?: Str::random(),
35 35
         ];
36
-        return $this->AuthorizeURL . '?' . http_build_query($params);
36
+        return $this->AuthorizeURL.'?'.http_build_query($params);
37 37
     }
38 38
 
39 39
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             'channel' => ConstCode::TYPE_LINE,
58 58
             'nickname'    => $result['displayName'],
59 59
             'gender'  => ConstCode::GENDER, //line不返回性别信息
60
-            'avatar'  => isset($result['pictureUrl']) ? $result['pictureUrl'] . '/large' : '',
60
+            'avatar'  => isset($result['pictureUrl']) ? $result['pictureUrl'].'/large' : '',
61 61
         ];
62 62
         return $userInfo;
63 63
     }
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
         $method  = strtoupper($method);
91 91
         $request = [
92 92
             'method' => $method,
93
-            'uri'    => self::API_BASE . $api,
93
+            'uri'    => self::API_BASE.$api,
94 94
         ];
95 95
 
96
-        $headers = ['Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']];
96
+        $headers = ['Authorization' => $this->token['token_type'].' '.$this->token['access_token']];
97 97
 
98 98
         $data = $this->$method($request['uri'], $params, $headers);
99 99
 
Please login to merge, or discard this patch.
src/OAuth.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     protected static function init($gateway, $config)
36 36
     {
37
-        if(empty($config)){
37
+        if (empty($config)) {
38 38
             throw new \Exception("第三方登录 [$gateway] config配置不能为空");
39 39
         }
40 40
         $baseConfig = [
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
             'scope'     => '',
45 45
             'type'      => '',
46 46
         ];
47
-        if($gateway == 'weixin'){
47
+        if ($gateway == 'weixin') {
48 48
             /** 兼容 tinymeng/oauth v1.0.0完美升级 */
49 49
             $gateway = 'wechat';
50 50
         }
51 51
         $gateway = Str::uFirst($gateway);
52
-        $class = __NAMESPACE__ . '\\Gateways\\' . $gateway;
52
+        $class = __NAMESPACE__.'\\Gateways\\'.$gateway;
53 53
         if (class_exists($class)) {
54
-            $app = new $class(array_replace_recursive($baseConfig,$config));
54
+            $app = new $class(array_replace_recursive($baseConfig, $config));
55 55
             if ($app instanceof GatewayInterface) {
56 56
                 return $app;
57 57
             }
Please login to merge, or discard this patch.
src/Gateways/Twitter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         $this->saveState();
28 28
         //登录参数
29 29
         $oauthToken = $this->call('oauth/request_token', ['oauth_callback' => $this->config['callback']], 'POST');
30
-        return self::API_BASE . 'oauth/authenticate?oauth_token=' . $oauthToken['oauth_token'];
30
+        return self::API_BASE.'oauth/authenticate?oauth_token='.$oauthToken['oauth_token'];
31 31
     }
32 32
 
33 33
     /**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             if (isset($this->token['oauth_token_secret'])) {
67 67
                 $this->tokenSecret = $this->token['oauth_token_secret'];
68 68
             } else {
69
-                throw new \Exception("获取Twitter ACCESS_TOKEN 出错:" . json_encode($this->token));
69
+                throw new \Exception("获取Twitter ACCESS_TOKEN 出错:".json_encode($this->token));
70 70
             }
71 71
         }
72 72
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $method  = strtoupper($method);
87 87
         $request = [
88 88
             'method' => $method,
89
-            'uri'    => self::API_BASE . $api,
89
+            'uri'    => self::API_BASE.$api,
90 90
         ];
91 91
         $oauthParams                    = $this->getOAuthParams($params);
92 92
         $oauthParams['oauth_signature'] = $this->signature($request, $oauthParams);
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
     {
132 132
         ksort($params);
133 133
         $sign_str = Str::buildParams($params, true);
134
-        $sign_str = $request['method'] . '&' . rawurlencode($request['uri']) . '&' . rawurlencode($sign_str);
135
-        $sign_key = $this->config['app_secret'] . '&' . $this->tokenSecret;
134
+        $sign_str = $request['method'].'&'.rawurlencode($request['uri']).'&'.rawurlencode($sign_str);
135
+        $sign_key = $this->config['app_secret'].'&'.$this->tokenSecret;
136 136
 
137 137
         return rawurlencode(base64_encode(hash_hmac('sha1', $sign_str, $sign_key, true)));
138 138
     }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     {
148 148
         $return = 'OAuth ';
149 149
         foreach ($params as $k => $param) {
150
-            $return .= $k . '="' . $param . '", ';
150
+            $return .= $k.'="'.$param.'", ';
151 151
         }
152 152
         return rtrim($return, ', ');
153 153
     }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      * 解析access_token方法请求后的返回值
169 169
      * @param string $token 获取access_token的方法的返回值
170 170
      */
171
-    protected function parseToken($token){
171
+    protected function parseToken($token) {
172 172
         return $token;
173 173
     }
174 174
 }
Please login to merge, or discard this patch.