@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | 'client_secret' => $this->appSecret, |
| 99 | 99 | ]; |
| 100 | 100 | |
| 101 | - if(!$byRefresh){ |
|
| 101 | + if (!$byRefresh) { |
|
| 102 | 102 | $params['redirect_uri'] = $redirectUrl; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $refreshToken = $this->tokenService->getRefreshToken(); |
| 136 | 136 | |
| 137 | - $response = $this->getAndSaveAccessToken($refreshToken , '', true); |
|
| 137 | + $response = $this->getAndSaveAccessToken($refreshToken, '', true); |
|
| 138 | 138 | |
| 139 | 139 | $prevHeaders['Authorization'] = 'Bearer ' . $response->access_token; |
| 140 | 140 | |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | 'Content-Type' => $contentType |
| 164 | 164 | ]; |
| 165 | 165 | return $this->sendRequest($url, $params, $headers, $method); |
| 166 | - }catch (Exception $e){ |
|
| 167 | - throw new Exception($e->getMessage(), (int)$e->getCode()); |
|
| 166 | + } catch (Exception $e) { |
|
| 167 | + throw new Exception($e->getMessage(), (int) $e->getCode()); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @return mixed|null |
| 177 | 177 | * @throws Exception |
| 178 | 178 | */ |
| 179 | - public function getFileInfo(string $fileId, $media = false, $params = []){ |
|
| 179 | + public function getFileInfo(string $fileId, $media = false, $params = []) { |
|
| 180 | 180 | $queryParam = $media ? '?alt=media' : '?fields=*'; |
| 181 | 181 | return $this->rpcRequest(GoogleDriveApp::FILE_METADATA_URL . '/' . $fileId . $queryParam, $params, 'GET'); |
| 182 | 182 | } |
@@ -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 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public function makeDirectory($dirname, $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'] === "drive#file" && $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'] === "drive#file" && $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; |
@@ -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'] |