diff options
Diffstat (limited to 'app/Helper')
-rw-r--r-- | app/Helper/App.php | 5 | ||||
-rw-r--r-- | app/Helper/Text.php | 23 |
2 files changed, 26 insertions, 2 deletions
diff --git a/app/Helper/App.php b/app/Helper/App.php index 0593795f..79afa5b9 100644 --- a/app/Helper/App.php +++ b/app/Helper/App.php @@ -17,11 +17,12 @@ class App extends Base * * @access public * @param string $param + * @param mixed $default_value * @return mixed */ - public function config($param) + public function config($param, $default_value = '') { - return $this->config->get($param); + return $this->config->get($param, $default_value); } /** diff --git a/app/Helper/Text.php b/app/Helper/Text.php index 59bfd997..83f1e3f9 100644 --- a/app/Helper/Text.php +++ b/app/Helper/Text.php @@ -43,6 +43,29 @@ class Text extends Base } /** + * Get the number of bytes from PHP size + * + * @param integer $val PHP size (example: 2M) + * @return integer + */ + public function phpToBytes($val) + { + $val = trim($val); + $last = strtolower($val[strlen($val)-1]); + + switch ($last) { + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + return $val; + } + + /** * Return true if needle is contained in the haystack * * @param string $haystack Haystack |