@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $this->setToken($data); |
| 90 | 90 | return true; |
| 91 | 91 | } else { |
| 92 | - throw new \RuntimeException('Failed to get token: ' . $data['message']); |
|
| 92 | + throw new \RuntimeException('Failed to get token: '.$data['message']); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $headers[] = "Accept: application/json"; |
| 117 | 117 | $body = json_encode($data); |
| 118 | 118 | |
| 119 | - $response = $this->curl($this->apiUrl . '/b2api/v1/' . $endpoint, $method, $headers, $body); |
|
| 119 | + $response = $this->curl($this->apiUrl.'/b2api/v1/'.$endpoint, $method, $headers, $body); |
|
| 120 | 120 | |
| 121 | 121 | if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) { |
| 122 | 122 | return $response->getJsonData(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | if ($response->getStatusCode() >= 400) { |
| 126 | 126 | $data = $response->getJsonData(); |
| 127 | - throw new \RuntimeException('Error ' . $response->getStatusCode() . ' - ' . $data['message']); |
|
| 127 | + throw new \RuntimeException('Error '.$response->getStatusCode().' - '.$data['message']); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | } |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | $this->CurlRequest->setOption(CURLOPT_POSTFIELDS, $body); |
| 149 | 149 | $this->CurlRequest->setOption(CURLOPT_HTTPHEADER, $headers); |
| 150 | 150 | $this->CurlRequest->setOption(CURLOPT_HEADERFUNCTION, |
| 151 | - function ($curl, $header) use ($response) { |
|
| 151 | + function($curl, $header) use ($response) { |
|
| 152 | 152 | $response->addHeader($header); |
| 153 | 153 | return strlen($header); |
| 154 | 154 | }); |
| 155 | 155 | |
| 156 | 156 | $resp = $this->CurlRequest->execute(); |
| 157 | 157 | if ($this->CurlRequest->getErrorNo() !== 0) { |
| 158 | - throw new \RuntimeException('curl error ' . $this->CurlRequest->getError() . '" - Code: ' . $this->CurlRequest->getErrorNo()); |
|
| 158 | + throw new \RuntimeException('curl error '.$this->CurlRequest->getError().'" - Code: '.$this->CurlRequest->getErrorNo()); |
|
| 159 | 159 | } else { |
| 160 | 160 | $response->setData($resp); |
| 161 | 161 | $response->setStatusCode($this->CurlRequest->getInfo(CURLINFO_HTTP_CODE)); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function buildBasicAuthHeader() |
| 170 | 170 | { |
| 171 | - return 'Authorization: Basic ' . base64_encode($this->accountId . ':' . $this->applicationKey); |
|
| 171 | + return 'Authorization: Basic '.base64_encode($this->accountId.':'.$this->applicationKey); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function buildTokenAuthHeader() |
| 178 | 178 | { |
| 179 | - return 'Authorization: ' . $this->authorizationToken; |
|
| 179 | + return 'Authorization: '.$this->authorizationToken; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | public function uploadData($fileData, $fileDataSha1, $fileName, $contentType, $uploadUrl, $uploadToken) |
| 190 | 190 | { |
| 191 | 191 | $headers = []; |
| 192 | - $headers[] = "Authorization: " . $uploadToken; |
|
| 193 | - $headers[] = "X-Bz-File-Name: " . $fileName; |
|
| 194 | - $headers[] = "Content-Type: " . $contentType; |
|
| 195 | - $headers[] = "X-Bz-Content-Sha1: " . $fileDataSha1; |
|
| 192 | + $headers[] = "Authorization: ".$uploadToken; |
|
| 193 | + $headers[] = "X-Bz-File-Name: ".$fileName; |
|
| 194 | + $headers[] = "Content-Type: ".$contentType; |
|
| 195 | + $headers[] = "X-Bz-Content-Sha1: ".$fileDataSha1; |
|
| 196 | 196 | |
| 197 | 197 | $response = $this->curl($uploadUrl, 'POST', $headers, $fileData); |
| 198 | 198 | return $response->getJsonData(); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | public function downloadFileByName($uri) |
| 205 | 205 | { |
| 206 | 206 | |
| 207 | - $uri = $this->downloadUrl . "/file/" . $uri; |
|
| 207 | + $uri = $this->downloadUrl."/file/".$uri; |
|
| 208 | 208 | $headers = [ |
| 209 | 209 | $this->buildTokenAuthHeader() |
| 210 | 210 | ]; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | if ($response->getStatusCode() === 200) { |
| 214 | 214 | return $response->getData(); |
| 215 | 215 | } else { |
| 216 | - throw new \RuntimeException('Download failed. ' . $response->getStatusCode()); |
|
| 216 | + throw new \RuntimeException('Download failed. '.$response->getStatusCode()); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | */ |
| 115 | 115 | public function downloadFileByName($bucketName, $fileName) |
| 116 | 116 | { |
| 117 | - return $this->B2Client->downloadFileByName($bucketName . '/' . $fileName); |
|
| 117 | + return $this->B2Client->downloadFileByName($bucketName.'/'.$fileName); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |