update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -15,12 +15,19 @@ use Symfony\Component\VarDumper\Dumper\CliDumper;
class DataFormatter implements DataFormatterInterface
{
/**
* DataFormatter constructor.
*/
public function __construct()
{
$this->cloner = new VarCloner();
$this->dumper = new CliDumper();
}
/**
* @param $data
* @return string
*/
public function formatVar($data)
{
$output = '';
@@ -39,6 +46,10 @@ class DataFormatter implements DataFormatterInterface
return trim($output);
}
/**
* @param float $seconds
* @return string
*/
public function formatDuration($seconds)
{
if ($seconds < 0.001) {
@@ -49,13 +60,22 @@ class DataFormatter implements DataFormatterInterface
return round($seconds, 2) . 's';
}
/**
* @param string $size
* @param int $precision
* @return string
*/
public function formatBytes($size, $precision = 2)
{
if ($size === 0 || $size === null) {
return "0B";
}
$sign = $size < 0 ? '-' : '';
$size = abs($size);
$base = log($size) / log(1024);
$suffixes = array('B', 'KB', 'MB', 'GB', 'TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
return $sign . round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
}
}