@@ -163,7 +163,7 @@ |
||
| 163 | 163 | 'Content-Type' => $contentType |
| 164 | 164 | ]; |
| 165 | 165 | return $this->sendRequest($url, $params, $headers, $method); |
| 166 | - }catch (Exception $e){ |
|
| 166 | + } catch (Exception $e){ |
|
| 167 | 167 | throw new Exception($e->getMessage(), (int)$e->getCode()); |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | 'client_secret' => $this->appSecret, |
| 109 | 109 | ]; |
| 110 | 110 | |
| 111 | - if(!$byRefresh){ |
|
| 111 | + if (!$byRefresh) { |
|
| 112 | 112 | $params['redirect_uri'] = $redirectUrl; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $refreshToken = $this->tokenService->getRefreshToken(); |
| 146 | 146 | |
| 147 | - $response = $this->fetchTokens($refreshToken , '', true); |
|
| 147 | + $response = $this->fetchTokens($refreshToken, '', true); |
|
| 148 | 148 | |
| 149 | 149 | $prevHeaders['Authorization'] = 'Bearer ' . $response->access_token; |
| 150 | 150 | |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | 'Content-Type' => $contentType |
| 176 | 176 | ]; |
| 177 | 177 | return $this->sendRequest($url, $params, $headers, $method); |
| 178 | - }catch (Exception $e){ |
|
| 179 | - throw new Exception($e->getMessage(), (int)$e->getCode()); |
|
| 178 | + } catch (Exception $e) { |
|
| 179 | + throw new Exception($e->getMessage(), (int) $e->getCode()); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @return mixed|null |
| 189 | 189 | * @throws Exception |
| 190 | 190 | */ |
| 191 | - public function getFileInfo(string $fileId, $media = false, $params = []){ |
|
| 191 | + public function getFileInfo(string $fileId, $media = false, $params = []) { |
|
| 192 | 192 | $queryParam = $media ? '?alt=media' : '?fields=*'; |
| 193 | 193 | return $this->rpcRequest(GoogleDriveApp::FILE_METADATA_URL . '/' . $fileId . $queryParam, $params, 'GET'); |
| 194 | 194 | } |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | try { |
| 83 | 83 | if($this->isFile($filename)){ |
| 84 | 84 | return $this->googleDriveApp->rpcRequest(GoogleDriveApp::FILE_MEDIA_URL . '/' . $filename . '?uploadType=media', $content, 'PATCH', 'application/octet-stream'); |
| 85 | - }else{ |
|
| 85 | + } else{ |
|
| 86 | 86 | $data = [ |
| 87 | 87 | 'name' => $filename, |
| 88 | 88 | 'parents' => $parentId ? [$parentId] : ['root'] |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public function makeDirectory(string $dirname, ?string $parentId = null): bool |
| 42 | 42 | { |
| 43 | - try{ |
|
| 43 | + try { |
|
| 44 | 44 | $data = [ |
| 45 | 45 | 'name' => $dirname, |
| 46 | 46 | 'mimeType' => GoogleDriveApp::FOLDER_MIMETYPE, |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | public function get(string $filename) |
| 69 | 69 | { |
| 70 | 70 | try { |
| 71 | - return (string)$this->googleDriveApp->getFileInfo($filename, true); |
|
| 71 | + return (string) $this->googleDriveApp->getFileInfo($filename, true); |
|
| 72 | 72 | } catch (Exception $e) { |
| 73 | 73 | return false; |
| 74 | 74 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | public function put(string $filename, string $content, ?string $parentId = null) |
| 81 | 81 | { |
| 82 | 82 | try { |
| 83 | - if($this->isFile($filename)){ |
|
| 83 | + if ($this->isFile($filename)) { |
|
| 84 | 84 | return $this->googleDriveApp->rpcRequest(GoogleDriveApp::FILE_MEDIA_URL . '/' . $filename . '?uploadType=media', $content, 'PATCH', 'application/octet-stream'); |
| 85 | - }else{ |
|
| 85 | + } else { |
|
| 86 | 86 | $data = [ |
| 87 | 87 | 'name' => $filename, |
| 88 | 88 | 'parents' => $parentId ? [$parentId] : ['root'] |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | public function size(string $filename) |
| 156 | 156 | { |
| 157 | 157 | try { |
| 158 | - $meta = (array)$this->googleDriveApp->getFileInfo($filename); |
|
| 158 | + $meta = (array) $this->googleDriveApp->getFileInfo($filename); |
|
| 159 | 159 | return $meta['size']; |
| 160 | 160 | } catch (Exception $e) { |
| 161 | 161 | return false; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | public function lastModified(string $filename) |
| 169 | 169 | { |
| 170 | 170 | try { |
| 171 | - $meta = (array)$this->googleDriveApp->getFileInfo($filename); |
|
| 171 | + $meta = (array) $this->googleDriveApp->getFileInfo($filename); |
|
| 172 | 172 | return !empty($meta['modifiedTime']) ? strtotime($meta['modifiedTime']) : false; |
| 173 | 173 | } catch (Exception $e) { |
| 174 | 174 | return false; |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | public function isFile(string $filename): bool |
| 197 | 197 | { |
| 198 | 198 | try { |
| 199 | - $meta = (array)$this->googleDriveApp->getFileInfo($filename); |
|
| 199 | + $meta = (array) $this->googleDriveApp->getFileInfo($filename); |
|
| 200 | 200 | |
| 201 | 201 | return $meta['kind'] === GoogleDriveApp::DRIVE_FILE_KIND && $meta['mimeType'] != GoogleDriveApp::FOLDER_MIMETYPE; |
| 202 | 202 | } catch (Exception $e) { |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | public function isDirectory(string $dirname): bool |
| 211 | 211 | { |
| 212 | 212 | try { |
| 213 | - $meta = (array)$this->googleDriveApp->getFileInfo($dirname); |
|
| 213 | + $meta = (array) $this->googleDriveApp->getFileInfo($dirname); |
|
| 214 | 214 | |
| 215 | 215 | return $meta['kind'] === GoogleDriveApp::DRIVE_FILE_KIND && $meta['mimeType'] === GoogleDriveApp::FOLDER_MIMETYPE; |
| 216 | 216 | } catch (Exception $e) { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | 'q' => "'$dirname' in parents and trashed = false", |
| 229 | 229 | 'fields' => '*' |
| 230 | 230 | ]; |
| 231 | - $response = (array)$this->googleDriveApp->rpcRequest(GoogleDriveApp::FILE_METADATA_URL . '?' . http_build_query($params), [], 'GET'); |
|
| 231 | + $response = (array) $this->googleDriveApp->rpcRequest(GoogleDriveApp::FILE_METADATA_URL . '?' . http_build_query($params), [], 'GET'); |
|
| 232 | 232 | return $response["files"]; |
| 233 | 233 | } catch (Exception $e) { |
| 234 | 234 | return false; |