Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Apr 18, 2017
1 parent 18a0be8 commit f71b9bb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/DropboxAdapter.php
Expand Up @@ -170,8 +170,6 @@ public function readStream($path)
*/
public function listContents($directory = '', $recursive = false): array
{
$listing = [];

$location = $this->applyPathPrefix($directory);

$result = $this->client->listContents($location, $recursive);
Expand All @@ -180,12 +178,12 @@ public function listContents($directory = '', $recursive = false): array
return [];
}

foreach ($result['entries'] as $object) {
$path = $this->removePathPrefix($object['path_display']);
$listing[] = $this->normalizeResponse($object, $path);
}
return array_map(function($entry) {
$path = $this->removePathPrefix($entry['path_display']);

return $this->normalizeResponse($entry, $path);

return $listing;
}, $result['entries']);
}

/**
Expand Down Expand Up @@ -217,7 +215,7 @@ public function getSize($path)
*/
public function getMimetype($path)
{
throw new LogicException('The Dropbox API v2 does not support mimetypes. Path: ' . $path);
throw new LogicException("The Dropbox API v2 does not support mimetypes. Given path: `{$path}`.");
}

/**
Expand Down Expand Up @@ -281,7 +279,9 @@ protected function normalizeResponse(array $response): array
$result['bytes'] = $response['size'];
}

$result['type'] = $response['.tag'] === 'folder' ? 'dir' : 'file';
$result['type'] = $response['.tag'] === 'folder'
? 'dir'
: 'file';

return $result;
}
Expand Down

0 comments on commit f71b9bb

Please sign in to comment.