Passed
Push — master ( 6395b8...2fcbd6 )
by ma
02:55
created
example/wx.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,23 +15,23 @@
 block discarded – undo
15 15
     ],
16 16
 ];
17 17
 
18
-$seq = $_GET['seq']??1;
19
-$limit = $_GET['limit']??10;
18
+$seq = $_GET['seq'] ?? 1;
19
+$limit = $_GET['limit'] ?? 10;
20 20
 
21 21
 try {
22 22
     $wxFinanceSDK = WxFinanceSDK::init($corpConfig);
23 23
     // 获取会话记录数据(解密)
24
-    $list = $wxFinanceSDK->getDecryptChatData($seq,$limit);
24
+    $list = $wxFinanceSDK->getDecryptChatData($seq, $limit);
25 25
 
26
-    foreach ($list as $key=>$item){
27
-        if($wxFinanceSDK->isMedia($item['msgtype'])){
26
+    foreach ($list as $key=>$item) {
27
+        if ($wxFinanceSDK->isMedia($item['msgtype'])) {
28 28
             // 下载媒体资源
29
-            $list[$key]['media_path'] = $wxFinanceSDK->getDownloadMediaData($item[$item['msgtype']],$item['msgtype']);
29
+            $list[$key]['media_path'] = $wxFinanceSDK->getDownloadMediaData($item[$item['msgtype']], $item['msgtype']);
30 30
         }
31 31
     }
32 32
     var_dump($list);
33 33
 
34
-}catch (FinanceSDKException $exception){
35
-    echo $exception->getMessage();exit();
34
+} catch (FinanceSDKException $exception) {
35
+    echo $exception->getMessage(); exit();
36 36
 }
37 37
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     }
32 32
     var_dump($list);
33 33
 
34
-}catch (FinanceSDKException $exception){
34
+} catch (FinanceSDKException $exception){
35 35
     echo $exception->getMessage();exit();
36 36
 }
37 37
 
Please login to merge, or discard this patch.
src/Provider/FFIProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
             // buffer写入文件
142 142
             $handle = fopen($path, 'ab+');
143
-            if (! $handle) {
143
+            if (!$handle) {
144 144
                 throw new \RuntimeException(sprintf('打开文件失败:%s', $path));
145 145
             }
146 146
 
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
      */
168 168
     protected function setFinanceSDK(array $config = []): void
169 169
     {
170
-        if (! extension_loaded('ffi')) {
170
+        if (!extension_loaded('ffi')) {
171 171
             throw new FinanceSDKException('缺少ext-ffi扩展');
172 172
         }
173 173
 
174 174
         $this->config = array_merge($this->config, $config);
175
-        if (! isset($this->config['corpid'])) {
175
+        if (!isset($this->config['corpid'])) {
176 176
             throw new InvalidArgumentException('缺少配置:corpid');
177 177
         }
178
-        if (! isset($this->config['secret'])) {
178
+        if (!isset($this->config['secret'])) {
179 179
             throw new InvalidArgumentException('缺少配置:secret');
180 180
         }
181 181
 
Please login to merge, or discard this patch.
src/Provider/AbstractProvider.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
      * @return Object SplFileInfo
76 76
      * @throws FinanceSDKException
77 77
      */
78
-    public function getDownloadMediaData($object,$msgType)
78
+    public function getDownloadMediaData($object, $msgType)
79 79
     {
80 80
         try {
81
-            $filePath = $this->getFilePath($object,$msgType);
82
-            return $this->getMediaData($object['sdkfileid'],$filePath);
81
+            $filePath = $this->getFilePath($object, $msgType);
82
+            return $this->getMediaData($object['sdkfileid'], $filePath);
83 83
         } catch (\Exception $e) {
84 84
             throw new FinanceSDKException($e->getMessage(), $e->getCode());
85 85
         }
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function isMedia($msgType): bool
94 94
     {
95
-        if(in_array($msgType,['image','voice','video','file','emotion'])){
95
+        if (in_array($msgType, ['image', 'voice', 'video', 'file', 'emotion'])) {
96 96
             return true;
97
-        }else{
97
+        }else {
98 98
             return false;
99 99
         }
100 100
     }
@@ -105,36 +105,36 @@  discard block
 block discarded – undo
105 105
      * @param $megType
106 106
      * @return string
107 107
      */
108
-    protected function getFilePath($object,$megType)
108
+    protected function getFilePath($object, $megType)
109 109
     {
110 110
         $config = $this->getConfig();
111
-        if(empty($config['path'])){
112
-            $config['path'] = sys_get_temp_dir() . '/' ;
111
+        if (empty($config['path'])) {
112
+            $config['path'] = sys_get_temp_dir() . '/';
113 113
         }
114 114
         $fileName = '';
115
-        switch ($megType){
115
+        switch ($megType) {
116 116
             case 'image':
117
-                $fileName = $object['md5sum']. ".jpg";
117
+                $fileName = $object['md5sum'] . ".jpg";
118 118
                 break;
119 119
             case 'voice':
120
-                $fileName = $object['md5sum']. ".mp3";
120
+                $fileName = $object['md5sum'] . ".mp3";
121 121
                 break;
122 122
             case 'video':
123
-                $fileName = $object['md5sum']. ".mp4";
123
+                $fileName = $object['md5sum'] . ".mp4";
124 124
                 break;
125 125
             case 'emotion':
126 126
                 // 表情类型,png或者gif.1表示gif 2表示png。Uint32类型
127
-                if($object['type'] == 1){
128
-                    $fileName = $object['md5sum']. ".gif";
129
-                }else{
130
-                    $fileName = $object['md5sum']. ".png";
127
+                if ($object['type'] == 1) {
128
+                    $fileName = $object['md5sum'] . ".gif";
129
+                }else {
130
+                    $fileName = $object['md5sum'] . ".png";
131 131
                 }
132 132
                 break;
133 133
             case 'file':
134 134
                 $fileName = $object['filename'];
135 135
             default:break;
136 136
         }
137
-        return $config['path'].$fileName;
137
+        return $config['path'] . $fileName;
138 138
     }
139 139
 
140 140
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     {
95 95
         if(in_array($msgType,['image','voice','video','file','emotion'])){
96 96
             return true;
97
-        }else{
97
+        } else{
98 98
             return false;
99 99
         }
100 100
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                 // 表情类型,png或者gif.1表示gif 2表示png。Uint32类型
127 127
                 if($object['type'] == 1){
128 128
                     $fileName = $object['md5sum']. ".gif";
129
-                }else{
129
+                } else{
130 130
                     $fileName = $object['md5sum']. ".png";
131 131
                 }
132 132
                 break;
Please login to merge, or discard this patch.
src/Provider/PHPExtProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,15 +78,15 @@
 block discarded – undo
78 78
      */
79 79
     protected function setFinanceSDK(array $config = []): void
80 80
     {
81
-        if (! extension_loaded('wxwork_finance_sdk')) {
81
+        if (!extension_loaded('wxwork_finance_sdk')) {
82 82
             throw new FinanceSDKException('缺少ext-wxwork_finance_sdk扩展');
83 83
         }
84 84
 
85 85
         $this->config = array_merge($this->config, $config);
86
-        if (! isset($this->config['corpid'])) {
86
+        if (!isset($this->config['corpid'])) {
87 87
             throw new InvalidArgumentException('缺少配置:corpid');
88 88
         }
89
-        if (! isset($this->config['secret'])) {
89
+        if (!isset($this->config['secret'])) {
90 90
             throw new InvalidArgumentException('缺少配置:secret');
91 91
         }
92 92
         $options                                                     = ['timeout' => 30];
Please login to merge, or discard this patch.
src/WxFinanceSDK.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     protected $wxConfig;
26 26
 
27 27
 
28
-    public function __construct(array $config = [],array $wxConfig = [])
28
+    public function __construct(array $config = [], array $wxConfig = [])
29 29
     {
30 30
         $default = [
31 31
             'default'   => 'php-ext',
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function provider($providerName): ProviderInterface
65 65
     {
66
-        if (! $this->config['providers'] || ! $this->config['providers'][$providerName]) {
66
+        if (!$this->config['providers'] || !$this->config['providers'][$providerName]) {
67 67
             throw new InvalidArgumentException("file configurations are missing {$providerName} options");
68 68
         }
69 69
         return (new $this->config['providers'][$providerName]['driver']())->setConfig($this->wxConfig);
Please login to merge, or discard this patch.