diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-03-04 20:10:34 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-03-04 20:10:34 -0500 |
commit | 8f3e2b2e5c62a6130f6c8867ab335fb4c1a32c5c (patch) | |
tree | ce28cdc2dba9c31560ef753ac1b4dc39d567b7a6 /app/Helper/Text.php | |
parent | f32507d423c46e8e9612b5239728e6c617e4cbcb (diff) |
Helper refactoring
Diffstat (limited to 'app/Helper/Text.php')
-rw-r--r-- | app/Helper/Text.php | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/app/Helper/Text.php b/app/Helper/Text.php deleted file mode 100644 index 83f1e3f9..00000000 --- a/app/Helper/Text.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -namespace Kanboard\Helper; - -use Kanboard\Core\Markdown; -use Kanboard\Core\Base; - -/** - * Text Helpers - * - * @package helper - * @author Frederic Guillot - */ -class Text extends Base -{ - /** - * Markdown transformation - * - * @param string $text Markdown content - * @param array $link Link parameters for replacement - * @return string - */ - public function markdown($text, array $link = array()) - { - $parser = new Markdown($this->container, $link); - $parser->setMarkupEscaped(MARKDOWN_ESCAPE_HTML); - return $parser->text($text); - } - - /** - * Format a file size - * - * @param integer $size Size in bytes - * @param integer $precision Precision - * @return string - */ - public function bytes($size, $precision = 2) - { - $base = log($size) / log(1024); - $suffixes = array('', 'k', 'M', 'G', 'T'); - - return round(pow(1024, $base - floor($base)), $precision).$suffixes[(int)floor($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 - * @param string $needle Needle - * @return boolean - */ - public function contains($haystack, $needle) - { - return strpos($haystack, $needle) !== false; - } - - /** - * Return a value from a dictionary - * - * @param mixed $id Key - * @param array $listing Dictionary - * @param string $default_value Value displayed when the key doesn't exists - * @return string - */ - public function in($id, array $listing, $default_value = '?') - { - if (isset($listing[$id])) { - return $this->helper->e($listing[$id]); - } - - return $default_value; - } -} |