54 $this->
string = strval($string);
65 return new self($string);
76 public function replace($search, $replace, $caseSensitivity = TRUE)
80 $this->
string = str_replace($search, $replace, $this->
string);
84 $this->
string = str_ireplace($search, $replace, $this->
string);
97 public function arg(array $args, $char =
"%")
99 $args = array_reverse($args, TRUE);
101 foreach($args as $key => $val)
103 $args[$char . $key] = $val;
107 $this->
string = strtr($this->
string, $args);
120 return (
substr($this->
string, 0, strlen($pattern)) == $pattern) ? TRUE : FALSE;
131 return (
substr($this->
string, strlen($pattern)*-1) == $pattern) ? TRUE : FALSE;
142 return strpos($this->
string, $needle);
153 return strrpos($this->
string, $needle);
163 return new self(strtolower($this->
string));
173 return new self(strtoupper($this->
string));
183 public function contains($pattern, $regexp = FALSE)
192 return (preg_match(
"/" . $pattern .
"/i", $this->
string)) ? TRUE : FALSE;
196 return (stristr($this->
string, $pattern) !== FALSE) ? TRUE : FALSE;
207 public function substr($start, $length = null)
209 $string = ($length !== null) ?
substr($this->
string, $start, $length) :
substr($this->
string, $start);
211 return new self($string);
221 public function split($separator, $limit = 0)
223 $parts = explode($separator, $this->
string, ($limit) ? intval($limit) : $this->
count());
225 foreach($parts as $key => $val)
227 $parts[$key] =
new self($val);
241 $this->
string = $this->
string . strval($part);
254 $this->
string = strval($part) . $this->string;
267 public function section($separator, $first = 0, $last = 0)
269 $sections = explode($separator, $this->
string);
271 $total =
count($sections);
272 $first = intval($first);
273 $last = intval($last);
275 if($first > $total)
return null;
276 if($first > $last) $last = $first;
278 for($i = 0; $i < $total; $i++)
280 if($i < $first || $i > $last)
282 unset($sections[$i]);
286 $string = implode($separator, $sections);
288 return new self($string);
298 public function resize($size, $char =
"\0")
300 $chars = ($size - $this->
count());
304 $this->
string =
substr($this->
string, 0, $chars);
308 $this->
string = str_pad($this->
string, $size, strval($char));
321 $this->
string =
trim($this->
string);
335 $this->
string = str_replace($search, $replace, $this->
string);
360 $this->
string = preg_replace(
"/[^[:alnum:]]/",
"", $this->
string);
372 $this->
string = preg_replace(
"/[^[:alpha:]]/",
"", $this->
string);
384 $this->
string = preg_replace(
"/[^[:digit:]]/",
"", $this->
string);
396 return (is_numeric($this->
string) && !$this->
contains(
".")) ? TRUE : FALSE;
407 if($this->
string == pow(2, 63) || $this->
string == pow(2, 64))
412 return ($this->
string > pow(2, 31)) ? floatval($this->
string) : intval($this->
string);
422 return crc32($this->
string);
432 return md5($this->
string);
442 return sha1($this->
string);
457 $pattern[] =
"[\xC2-\xDF][\x80-\xBF]";
458 $pattern[] =
"\xE0[\xA0-\xBF][\x80-\xBF]";
459 $pattern[] =
"[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}";
460 $pattern[] =
"\xED[\x80-\x9F][\x80-\xBF]";
461 $pattern[] =
"\xF0[\x90-\xBF][\x80-\xBF]{2}";
462 $pattern[] =
"[\xF1-\xF3][\x80-\xBF]{3}";
463 $pattern[] =
"\xF4[\x80-\x8F][\x80-\xBF]{2}";
465 return preg_match(
"%(?:" . implode(
"|", $pattern) .
")+%xs", $this->
string);
477 $this->
string = utf8_encode($this->
string);
490 return base64_encode($this->
string);
501 return new self(base64_decode($base64));
513 foreach($this as $char)
515 $hex .= $char->toHex();
532 if(strlen($hex)%2 == 1)
537 foreach(str_split($hex, 2) as $chunk)
539 $string .= chr(hexdec($chunk));
542 return new self($string);
552 $utf8_accents = array(
763 return new self($this->
toUtf8()->replace(array_keys($utf8_accents), array_values($utf8_accents)));
775 $this->
string = str_replace($spacer,
" ", $this->
string);
777 $this->
string = preg_replace(
"/(\s|[^A-Za-z0-9\-])+/", $spacer,
trim(strtolower($this->
string)));
778 $this->
string =
trim($this->
string, $spacer);
780 return new self($this->string);
790 return str_replace(
" ",
"%20", $this->
string);
800 return $this->string;
813 if(!function_exists($function))
820 if(($key = array_search($this, $args, TRUE)) !== FALSE)
822 $args[$key] = $this->string;
826 throw new TeamSpeak3_Helper_Exception(
"cannot call undefined function '" . $function .
"' without the " . __CLASS__ .
" object parameter");
829 $return = call_user_func_array($function, $args);
833 $return = call_user_func($function, $this->
string);
836 if(is_string($return))
838 $this->
string = $return;
855 return (
string) $this->string;
863 return strlen($this->
string);
879 return $this->position < $this->
count();
911 return ($offset < strlen($this->
string)) ? TRUE : FALSE;
929 $this->
string{$offset} = strval($value);
939 $this->
string = substr_replace($this->
string,
"", $offset, 1);