Passed
Push — master ( 440c07...c6a73c )
by Liam
11:16 queued 09:00
created
src/FeiYu.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 
39 39
   public function __construct($options)
40 40
   {
41
-    $this->host = isset($options['host'])?$options['host']:$this->host;
42
-    $this->pull_route = isset($options['pull_route'])?$options['pull_route']:$this->pull_route;
43
-    $this->push_route = isset($options['push_route'])?$options['push_route']:$this->push_route;
44
-    $this->signature_key = isset($options['signature_key'])?$options['signature_key']:$this->signature_key;
45
-    $this->token = isset($options['token'])?$options['token']:$this->token;
41
+    $this->host = isset($options['host']) ? $options['host'] : $this->host;
42
+    $this->pull_route = isset($options['pull_route']) ? $options['pull_route'] : $this->pull_route;
43
+    $this->push_route = isset($options['push_route']) ? $options['push_route'] : $this->push_route;
44
+    $this->signature_key = isset($options['signature_key']) ? $options['signature_key'] : $this->signature_key;
45
+    $this->token = isset($options['token']) ? $options['token'] : $this->token;
46 46
     $this->timestamp = time();
47 47
   }
48 48
 
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
    */
70 70
   public function pushData($data)
71 71
   {
72
-    if(!isset($data['clue_convert_state']) || !isset($data['clue_id'])){
72
+    if (!isset($data['clue_convert_state']) || !isset($data['clue_id'])) {
73 73
       throw new \Exception("上传数据缺少必要的参数", 1);
74 74
     }
75
-    if(!is_numeric($data['clue_convert_state'])){
75
+    if (!is_numeric($data['clue_convert_state'])) {
76 76
       throw new \Exception("clue_convert_state 必须是数字类型", 1);
77 77
     }
78
-    $data['clue_convert_state'] = (int)$data['clue_convert_state'];
78
+    $data['clue_convert_state'] = (int) $data['clue_convert_state'];
79 79
     $this->push_data = json_encode([
80 80
       'source' => 0,
81 81
       'data' => [
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
       }
114 114
 
115 115
       $page++;
116
-    } while (($page-1)*($this->page_size) < $this->res_data['count']);
116
+    } while (($page - 1) * ($this->page_size) < $this->res_data['count']);
117 117
 
118 118
     return true;
119 119
   }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
   protected function encryptData()
126 126
   {
127 127
     // 拼接中的空格很重要
128
-    if($this->fetch_route == $this->pull_route){
128
+    if ($this->fetch_route == $this->pull_route) {
129 129
       $data = $this->fetch_route.'?start_time='.$this->start_time.'&end_time='.$this->end_time.' '.$this->timestamp;
130 130
     } else {
131 131
       $data = $this->fetch_route.' '.$this->timestamp;
@@ -148,23 +148,23 @@  discard block
 block discarded – undo
148 148
     curl_setopt($ch, CURLOPT_TIMEOUT, 5);
149 149
     curl_setopt($ch, CURLOPT_HTTPHEADER, [
150 150
         'Content-Type: application/json;charset=UTF-8',
151
-        'Signature: ' . $this->signature,
152
-        'Timestamp: ' . $this->timestamp,
153
-        'Access-Token: ' . $this->token,
151
+        'Signature: '.$this->signature,
152
+        'Timestamp: '.$this->timestamp,
153
+        'Access-Token: '.$this->token,
154 154
     ]);
155
-    if($this->fetch_route == $this->push_route){
155
+    if ($this->fetch_route == $this->push_route) {
156 156
       curl_setopt($ch, CURLOPT_POST, true);
157 157
       curl_setopt($ch, CURLOPT_POSTFIELDS, $this->push_data);
158 158
     }
159 159
     $output = curl_exec($ch);
160 160
     $error = curl_error($ch);
161 161
     curl_close($ch);
162
-    if($error != ''){
162
+    if ($error != '') {
163 163
       throw new FeiYuException($error, 1);
164 164
     }
165 165
     $this->res_data = json_decode($output, true);
166
-    if($this->res_data['status'] != 'success'){
167
-      if(is_array($this->res_data['msg'])){
166
+    if ($this->res_data['status'] != 'success') {
167
+      if (is_array($this->res_data['msg'])) {
168 168
         throw new FeiYuException(json_encode($this->res_data['msg']), 1);
169 169
       }
170 170
       throw new FeiYuException($this->res_data['msg'], 1);
Please login to merge, or discard this patch.