1 | <?php |
||
16 | class Adapter extends AbstractAdapter |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $driver = "google"; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $providerClass = Provider::class; |
||
27 | |||
28 | /** |
||
29 | * @param $user |
||
30 | * |
||
31 | * @return array |
||
32 | */ |
||
33 | protected function mapUserDetails($user) |
||
34 | { |
||
35 | return [ |
||
36 | 'name' => $user->name, |
||
37 | 'email' => $user->email, |
||
38 | ]; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @return Quota |
||
43 | */ |
||
44 | public function getQuota() |
||
45 | { |
||
46 | $about = $this->service()->about->get(); |
||
47 | |||
48 | return new Quota($about->getQuotaBytesTotal(), $about->getQuotaBytesUsed()); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return Google_Service_Drive |
||
53 | */ |
||
54 | protected function makeService() |
||
73 | |||
74 | /** |
||
75 | * @param UploadRequest $request |
||
76 | * |
||
77 | * @return string |
||
78 | * |
||
79 | */ |
||
80 | public function upload( UploadRequest $request ) |
||
81 | { |
||
82 | $file = $this->prepareFile($request->getDestinationPath()); |
||
83 | list($filesize, $mimeType) = $this->stat($request->getSourcePath()); |
||
84 | |||
85 | if ($filesize >= 5 * 1024 * 1024) { |
||
86 | return $this->uploadChunked($request->getSourcePath(), $file, $filesize); |
||
87 | } |
||
88 | |||
89 | return $this->service()->files->create($file, [ |
||
90 | 'data' => file_get_contents($request->getSourcePath()), |
||
91 | 'mimeType' => $mimeType, |
||
92 | 'uploadType' => 'media', |
||
93 | ])->id; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @param $destinationPath |
||
98 | * |
||
99 | * @return Google_Service_Drive_DriveFile |
||
100 | */ |
||
101 | protected function prepareFile( $destinationPath ) |
||
110 | |||
111 | /** |
||
112 | * @param $sourcePath |
||
113 | * |
||
114 | * @return array |
||
115 | */ |
||
116 | protected function stat( $sourcePath ) |
||
125 | |||
126 | /** |
||
127 | * @param $path |
||
128 | * |
||
129 | * @return mixed |
||
130 | */ |
||
131 | protected function getFolderIdForPath( $path ) |
||
137 | |||
138 | /** |
||
139 | * @param $sourcePath |
||
140 | * @param Google_Service_Drive_DriveFile $file |
||
141 | * @param $filesize |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | protected function uploadChunked( $sourcePath, Google_Service_Drive_DriveFile $file, $filesize ) |
||
175 | |||
176 | /** |
||
177 | * @param array $folders |
||
178 | * @param string $parentFolderId |
||
179 | * |
||
180 | * @return mixed |
||
181 | */ |
||
182 | protected function prepareFolderTree( array $folders, $parentFolderId = 'root' ) |
||
202 | |||
203 | /** |
||
204 | * @param $name |
||
205 | * @param string $parentFolderId |
||
206 | * |
||
207 | * @return mixed |
||
208 | */ |
||
209 | protected function folderExists( $name, $parentFolderId = 'root' ) |
||
219 | |||
220 | public function checkUploadStatus( UploadResponse $response ) |
||
221 | { |
||
222 | |||
224 | |||
225 | public function pathExists($remotePath) |
||
229 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: