setValue($value); } function escapePhp() { return new self(addcslashes($this->getValue(), '"\\$')); } function __toString() { return (string) $this->getValue(); } function setValue($value) { $this->value = $value; } function getValue() { return $this->value; } function wrapTag ($tag) { $result = '<' . $tag . '>'; $result .= $result; $result .= ''; return new self($result); } function humanFileSize ($precision=2) { $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); $bytes = $this->getValue(); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return new self(round($bytes, $precision) . ' ' . $units[$pow]); } function underscoreCamel() { return new self(strtolower(preg_replace('/([A-Z])/', '_\1', $this->getValue()))); } function camelize() { $string = preg_replace('/_+/', " ", $this->getValue()); $string = ucwords(strtolower($string)); if ($string) { $first_letter = substr($string, 0, 1); $string = strtolower($first_letter) . substr($string, 1); $string = preg_replace('/\s+/', '', $string); } return new self($string); } function toUrl () { $result = strtolower ($this->getValue ()); $result = preg_replace ('/[^a-z\d]/', '-', $result); $result = preg_replace ('/\-+/', '-', $result); $result = trim ($result, '-'); return new self ($result); } function toInteger () { sscanf ($this->getValue (), '%u%c', $number, $suffix); if (isset ($suffix)) { $number = $number * pow (1024, strpos (' KMG', $suffix)); } return $number; } }