Browse Source

Move get_file_size() helper function to helpers.php.

Franz Liedke 12 years ago
parent
commit
6b5cccc15f
2 changed files with 14 additions and 14 deletions
  1. 12 0
      laravel/helpers.php
  2. 2 14
      laravel/profiling/profiler.php

+ 12 - 0
laravel/helpers.php

@@ -580,4 +580,16 @@ function get_cli_option($option, $default = null)
 	}
 
 	return value($default);
+}
+	
+/**
+ * Calculate the human-readable file size (with proper units).
+ *
+ * @param  int     $size
+ * @return string
+ */
+function get_file_size($size)
+{
+	$units = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB');
+	return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$units[$i];
 }

+ 2 - 14
laravel/profiling/profiler.php

@@ -28,24 +28,12 @@ class Profiler {
 		// type applications, so we will not send anything in those scenarios.
 		if ( ! Request::ajax())
 		{
-			static::$data['memory'] = static::get_file_size(memory_get_usage(true));
-			static::$data['memory_peak'] = static::get_file_size(memory_get_peak_usage(true));
+			static::$data['memory'] = get_file_size(memory_get_usage(true));
+			static::$data['memory_peak'] = get_file_size(memory_get_peak_usage(true));
 			static::$data['time'] = number_format((microtime(true) - LARAVEL_START) * 1000, 2);
 			return render('path: '.__DIR__.'/template'.BLADE_EXT, static::$data);
 		}
 	}
-	
-	/**
-	 * Calculate the human-readable file size (with proper units).
-	 *
-	 * @param  int  $size
-	 * @return string
-	 */
-	private static function get_file_size($size)
-	{
-		$units = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB');
-		return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$units[$i];
-	}
 
 	/**
 	 * Add a log entry to the log entries array.