Skip to content

Commit

Permalink
Merge pull request #10 from masbug/analysis-nNQdGG
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
masbug authored Dec 14, 2020
2 parents f1434e0 + 072a111 commit d50fd85
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
56 changes: 28 additions & 28 deletions src/GoogleDriveAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ protected function cleanOptParameters($parameters)
public function write($path, $contents, Config $config)
{
$updating = null;

if($this->useDisplayPaths) {
try {
$virtual_path = $this->toVirtualPath($path, true, false);
$updating = true; // destination exists
} catch(FileNotFoundException $e) {
$updating = false;
list($parentDir, $fileName) = $this->splitPath($path, false);
[$parentDir, $fileName] = $this->splitPath($path, false);
$virtual_path = $this->toSingleVirtualPath($parentDir, false, true, true, true);
if($virtual_path === '')
$virtual_path = $fileName;
Expand All @@ -318,7 +318,7 @@ function ($p) {
} else {
$virtual_path = $path;
}

return $this->upload($virtual_path, $contents, $config, $updating);
}

Expand Down Expand Up @@ -364,12 +364,12 @@ public function rename($path, $newpath)
if($toPath === '')
$toPath = $this->root;

list($oldParent, $fileId) = $this->splitPath($path);
[$oldParent, $fileId] = $this->splitPath($path);
$newParent = $toPath;
$newName = basename($newpath);
} else {
list($oldParent, $fileId) = $this->splitPath($path);
list($newParent, $newName) = $this->splitPath($newpath);
[$oldParent, $fileId] = $this->splitPath($path);
[$newParent, $newName] = $this->splitPath($newpath);
}

$file = new Google_Service_Drive_DriveFile();
Expand Down Expand Up @@ -416,8 +416,8 @@ public function copy($path, $newpath)
$newParentId = $toPath;
$fileName = basename($newpath);
} else {
list(, $srcId) = $this->splitPath($path);
list($newParentId, $fileName) = $this->splitPath($newpath);
[, $srcId] = $this->splitPath($path);
[$newParentId, $fileName] = $this->splitPath($newpath);
}

$file = new Google_Service_Drive_DriveFile();
Expand All @@ -427,8 +427,8 @@ public function copy($path, $newpath)
]);

$newFile = $this->service->files->copy($srcId, $file, $this->applyDefaultParams([
'fields' => self::FETCHFIELDS_GET
], 'files.copy'));
'fields' => self::FETCHFIELDS_GET
], 'files.copy'));

if($newFile instanceof Google_Service_Drive_DriveFile) {
$id = $newFile->getId();
Expand Down Expand Up @@ -487,7 +487,7 @@ public function delete($path)
$deleted = $this->delete_by_id($ids);
} else {
if(($file = $this->getFileObject($path))) {
list($parentId, $id) = $this->splitPath($path);
[$parentId, $id] = $this->splitPath($path);
if(($parents = $file->getParents())) {
$file = new Google_Service_Drive_DriveFile();
$opts = [];
Expand Down Expand Up @@ -537,7 +537,7 @@ public function createDir($dirname, Config $config, $internalCall = false)
];
}

list($pdir, $name) = $this->splitPath($dirname, false);
[$pdir, $name] = $this->splitPath($dirname, false);
if($this->useDisplayPaths) {
if($pdir !== $this->root) {
$pdir = $this->toSingleVirtualPath($pdir, false, false, true, true); // recursion!
Expand Down Expand Up @@ -588,7 +588,7 @@ public function read($path)
if($this->useDisplayPaths) {
$fileId = $this->toVirtualPath($path, false, true);
} else {
list(, $fileId) = $this->splitPath($path);
[, $fileId] = $this->splitPath($path);
}
/** @var RequestInterface $response */
if(($response = $this->service->files->get($fileId, $this->applyDefaultParams(['alt' => 'media'], 'files.get')))) {
Expand Down Expand Up @@ -1052,7 +1052,7 @@ protected function normaliseObject(Google_Service_Drive_DriveFile $object, $dirn
*/
protected function getItems($dirname, $recursive = false, $maxResults = 0, $query = '')
{
list(, $itemId) = $this->splitPath($dirname);
[, $itemId] = $this->splitPath($dirname);

$maxResults = min($maxResults, 1000);
$results = [];
Expand Down Expand Up @@ -1121,7 +1121,7 @@ protected function getItems($dirname, $recursive = false, $maxResults = 0, $quer
*/
public function getFileObject($path, $checkDir = false)
{
list(, $itemId) = $this->splitPath($path);
[, $itemId] = $this->splitPath($path);
if(isset($this->cacheFileObjects[$itemId])) {
return $this->cacheFileObjects[$itemId];
}
Expand All @@ -1144,16 +1144,16 @@ public function getFileObject($path, $checkDir = false)
if($checkDir && $this->useHasDir) {
/** @var RequestInterface $request */
$request = $service->files->listFiles($this->applyDefaultParams([
'pageSize' => 1,
'orderBy' => 'folder,modifiedTime,name',
'q' => sprintf('trashed = false and "%s" in parents and mimeType = "%s"', $itemId, self::DIRMIME)
], 'files.list'));
'pageSize' => 1,
'orderBy' => 'folder,modifiedTime,name',
'q' => sprintf('trashed = false and "%s" in parents and mimeType = "%s"', $itemId, self::DIRMIME)
], 'files.list'));

$batch->add($request, 'hasdir');
}
$results = array_values($batch->execute());

list($fileObj, $hasdir) = array_pad($results, 2, null);
[$fileObj, $hasdir] = array_pad($results, 2, null);
} finally {
$client->setUseBatch(false);
}
Expand Down Expand Up @@ -1220,8 +1220,8 @@ protected function createDirectory($name, $parentId)
$file->setMimeType(self::DIRMIME);

$obj = $this->service->files->create($file, $this->applyDefaultParams([
'fields' => self::FETCHFIELDS_GET
], 'files.create'));
'fields' => self::FETCHFIELDS_GET
], 'files.create'));
$this->resetRequest($parentId);

return ($obj instanceof Google_Service_Drive_DriveFile) ? $obj : null;
Expand All @@ -1238,7 +1238,7 @@ protected function createDirectory($name, $parentId)
*/
protected function upload($path, $contents, Config $config, $updating = null)
{
list($parentId, $fileName) = $this->splitPath($path);
[$parentId, $fileName] = $this->splitPath($path);
$mime = $config->get('mimetype');
$file = new Google_Service_Drive_DriveFile();

Expand Down Expand Up @@ -1376,10 +1376,10 @@ protected function getObjects($ids, $checkDir = false)
if($checkDir) {
/** @var RequestInterface $request */
$request = $service->files->listFiles($this->applyDefaultParams([
'pageSize' => 1,
'orderBy' => 'folder,modifiedTime,name',
'q' => sprintf('trashed = false and "%s" in parents and mimeType = "%s"', $itemId, self::DIRMIME)
], 'files.list'));
'pageSize' => 1,
'orderBy' => 'folder,modifiedTime,name',
'q' => sprintf('trashed = false and "%s" in parents and mimeType = "%s"', $itemId, self::DIRMIME)
], 'files.list'));
$batch->add($request, 'hasdir-'.$itemId);
$count++;
}
Expand Down Expand Up @@ -1745,7 +1745,7 @@ protected function toVirtualPath($displayPath, $makeFullVirtualPath = true, $ret
$indices = $this->indexString($displayPath, '/');
$indices[] = strlen($displayPath);

list($itemId, $pathMatch) = $this->getCachedPathId($displayPath, $indices);
[$itemId, $pathMatch] = $this->getCachedPathId($displayPath, $indices);
$i = 0;
if($pathMatch !== null) {
if(strcmp($pathMatch, $displayPath) === 0) {
Expand Down
14 changes: 7 additions & 7 deletions src/StreamableUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ class StreamableUpload
const UPLOAD_MULTIPART_TYPE = 'multipart';
const UPLOAD_RESUMABLE_TYPE = 'resumable';

/** @var string $mimeType */
/** @var string */
private $mimeType;

/** @var null|StreamInterface $data */
/** @var null|StreamInterface */
private $data;

/** @var bool $resumable */
/** @var bool */
private $resumable;

/** @var int $chunkSize */
/** @var int */
private $chunkSize;

/** @var int|string $size */
/** @var int|string */
private $size;

/** @var string $resumeUri */
/** @var string */
private $resumeUri;

/** @var int $progress */
/** @var int */
private $progress;

/** @var Google_Client */
Expand Down

0 comments on commit d50fd85

Please sign in to comment.