private function BackupMigrateDropboxAPI::byte_size in Backup and Migrate Dropbox 7.3
Same name and namespace in other branches
- 7.2 backup_migrate_dropbox.dropbox_api.inc \BackupMigrateDropboxAPI::byte_size()
Converts a size pattern to a numeric size.
Code pulled from Stack Overflow: http://stackoverflow.com/q/1336581/819883.
Parameters
string $byteString:
Return value
int
1 call to BackupMigrateDropboxAPI::byte_size()
- BackupMigrateDropboxAPI::file_upload in ./
backup_migrate_dropbox.dropbox_api.inc - Uploads a file to the given path.
File
- ./
backup_migrate_dropbox.dropbox_api.inc, line 826
Class
- BackupMigrateDropboxAPI
- BackupMigrateDropboxAPI contains all the details about the Dropbox api, authorization calls, endpoints, uris, parameters, error handling, and split requests for large uploads/downloads
Code
private function byte_size($byteString) {
preg_match('/^\\s*([0-9.]+)\\s*([KMGT])B?\\s*$/i', $byteString, $matches);
if (!(count($matches) >= 3)) {
return 0;
}
$num = (double) $matches[1];
switch (strtoupper($matches[2])) {
/** @noinspection PhpMissingBreakStatementInspection */
case 'T':
$num *= DRUPAL_KILOBYTE;
/** @noinspection PhpMissingBreakStatementInspection */
case 'G':
$num *= DRUPAL_KILOBYTE;
/** @noinspection PhpMissingBreakStatementInspection */
case 'M':
$num *= DRUPAL_KILOBYTE;
case 'K':
$num *= DRUPAL_KILOBYTE;
}
return intval($num);
}