TeamSpeak 3 PHP Framework  1.1.23
Copyright © Planet TeamSpeak. All rights reserved.
 All Classes Namespaces Files Functions Variables Pages
TeamSpeak3_Helper_String Class Reference

Helper class for string handling. More...

+ Inheritance diagram for TeamSpeak3_Helper_String:

Public Member Functions

 __construct ($string)
 The TeamSpeak3_Helper_String constructor. More...
 
 replace ($search, $replace, $caseSensitivity=TRUE)
 Replaces every occurrence of the string $search with the string $replace. More...
 
 arg (array $args, $char="%")
 This function replaces indexed or associative signs with given values. More...
 
 startsWith ($pattern)
 Returns true if the string starts with $pattern. More...
 
 endsWith ($pattern)
 Returns true if the string ends with $pattern. More...
 
 findFirst ($needle)
 Returns the position of the first occurrence of a char in a string. More...
 
 findLast ($needle)
 Returns the position of the last occurrence of a char in a string. More...
 
 toLower ()
 Returns the lowercased string. More...
 
 toUpper ()
 Returns the uppercased string. More...
 
 contains ($pattern, $regexp=FALSE)
 Returns true if the string contains $pattern. More...
 
 substr ($start, $length=null)
 Returns part of a string. More...
 
 split ($separator, $limit=0)
 Splits the string into substrings wherever $separator occurs. More...
 
 append ($part)
 Appends $part to the string. More...
 
 prepend ($part)
 Prepends $part to the string. More...
 
 section ($separator, $first=0, $last=0)
 Returns a section of the string. More...
 
 resize ($size, $char="\0")
 Sets the size of the string to $size characters. More...
 
 trim ()
 Strips whitespaces (or other characters) from the beginning and end of the string. More...
 
 escape ()
 Escapes a string using the TeamSpeak 3 escape patterns. More...
 
 unescape ()
 Unescapes a string using the TeamSpeak 3 escape patterns. More...
 
 filterAlnum ()
 Removes any non alphanumeric characters from the string. More...
 
 filterAlpha ()
 Removes any non alphabetic characters from the string. More...
 
 filterDigits ()
 Removes any non numeric characters from the string. More...
 
 isInt ()
 Returns TRUE if the string is a numeric value. More...
 
 toInt ()
 Returns the integer value of the string. More...
 
 toCrc32 ()
 Calculates and returns the crc32 polynomial of the string. More...
 
 toMd5 ()
 Calculates and returns the md5 checksum of the string. More...
 
 toSha1 ()
 Calculates and returns the sha1 checksum of the string. More...
 
 isUtf8 ()
 Returns TRUE if the string is UTF-8 encoded. More...
 
 toUtf8 ()
 Converts the string to UTF-8. More...
 
 toBase64 ()
 Encodes the string with MIME base64 and returns the result. More...
 
 toHex ()
 Returns the hexadecimal value of the string. More...
 
 transliterate ()
 Returns the string transliterated from UTF-8 to Latin. More...
 
 uriSafe ($spacer="-")
 Processes the string and replaces all accented UTF-8 characters by unaccented ASCII-7 "equivalents", whitespaces are replaced by a pre-defined spacer and the string is lowercase. More...
 
 spaceToPercent ()
 Replaces space characters with percent encoded strings. More...
 
 toString ()
 Returns the string as a standard string. More...
 
 __call ($function, $args)
 Magical function that allows you to call PHP's built-in string functions on the TeamSpeak3_Helper_String object. More...
 
 __toString ()
 Returns the character as a standard string. More...
 
 count ()
 
 rewind ()
 
 valid ()
 
 key ()
 
 current ()
 
 next ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 

Static Public Member Functions

static factory ($string)
 Returns a TeamSpeak3_Helper_String object for thegiven string. More...
 
static fromBase64 ($base64)
 Decodes the string with MIME base64 and returns the result as an TeamSpeak3_Helper_String. More...
 
static fromHex ($hex)
 Returns the TeamSpeak3_Helper_String based on a given hex value. More...
 

Protected Attributes

 $string
 
 $position = 0
 

Detailed Description

Helper class for string handling.

Definition at line 32 of file String.php.

Constructor & Destructor Documentation

TeamSpeak3_Helper_String::__construct (   $string)

The TeamSpeak3_Helper_String constructor.

Parameters
string$string
Returns
TeamSpeak3_Helper_String

Definition at line 52 of file String.php.

53  {
54  $this->string = strval($string);
55  }

Member Function Documentation

TeamSpeak3_Helper_String::replace (   $search,
  $replace,
  $caseSensitivity = TRUE 
)

Replaces every occurrence of the string $search with the string $replace.

Parameters
string$search
string$replace
boolean$caseSensitivity
Returns
TeamSpeak3_Helper_String

Definition at line 76 of file String.php.

77  {
78  if($caseSensitivity)
79  {
80  $this->string = str_replace($search, $replace, $this->string);
81  }
82  else
83  {
84  $this->string = str_ireplace($search, $replace, $this->string);
85  }
86 
87  return $this;
88  }
TeamSpeak3_Helper_String::arg ( array  $args,
  $char = "%" 
)

This function replaces indexed or associative signs with given values.

Parameters
array$args
string$char
Returns
TeamSpeak3_Helper_String

Definition at line 97 of file String.php.

Referenced by TeamSpeak3_Exception\prepareCustomMessage().

98  {
99  $args = array_reverse($args, TRUE);
100 
101  foreach($args as $key => $val)
102  {
103  $args[$char . $key] = $val;
104  unset($args[$key]);
105  }
106 
107  $this->string = strtr($this->string, $args);
108 
109  return $this;
110  }
TeamSpeak3_Helper_String::startsWith (   $pattern)

Returns true if the string starts with $pattern.

Parameters
string$pattern
Returns
boolean

Definition at line 118 of file String.php.

References substr().

Referenced by TeamSpeak3_Adapter_ServerQuery_Event\__construct().

119  {
120  return (substr($this->string, 0, strlen($pattern)) == $pattern) ? TRUE : FALSE;
121  }
TeamSpeak3_Helper_String::endsWith (   $pattern)

Returns true if the string ends with $pattern.

Parameters
string$pattern
Returns
boolean

Definition at line 129 of file String.php.

References substr().

130  {
131  return (substr($this->string, strlen($pattern)*-1) == $pattern) ? TRUE : FALSE;
132  }
TeamSpeak3_Helper_String::findFirst (   $needle)

Returns the position of the first occurrence of a char in a string.

Parameters
string$needle
Returns
integer

Definition at line 140 of file String.php.

141  {
142  return strpos($this->string, $needle);
143  }
TeamSpeak3_Helper_String::findLast (   $needle)

Returns the position of the last occurrence of a char in a string.

Parameters
string$needle
Returns
integer

Definition at line 151 of file String.php.

152  {
153  return strrpos($this->string, $needle);
154  }
TeamSpeak3_Helper_String::toLower ( )

Returns the lowercased string.

Returns
TeamSpeak3_Helper_String

Definition at line 161 of file String.php.

162  {
163  return new self(strtolower($this->string));
164  }
TeamSpeak3_Helper_String::toUpper ( )

Returns the uppercased string.

Returns
TeamSpeak3_Helper_String

Definition at line 171 of file String.php.

172  {
173  return new self(strtoupper($this->string));
174  }
TeamSpeak3_Helper_String::contains (   $pattern,
  $regexp = FALSE 
)

Returns true if the string contains $pattern.

Parameters
string$pattern
booean$regexp
Returns
boolean

Definition at line 183 of file String.php.

Referenced by isInt().

184  {
185  if(empty($pattern))
186  {
187  return TRUE;
188  }
189 
190  if($regexp)
191  {
192  return (preg_match("/" . $pattern . "/i", $this->string)) ? TRUE : FALSE;
193  }
194  else
195  {
196  return (stristr($this->string, $pattern) !== FALSE) ? TRUE : FALSE;
197  }
198  }
TeamSpeak3_Helper_String::substr (   $start,
  $length = null 
)

Returns part of a string.

Parameters
integer$start
integer$length
Returns
TeamSpeak3_Helper_String

Definition at line 207 of file String.php.

Referenced by endsWith(), resize(), and startsWith().

208  {
209  $string = ($length !== null) ? substr($this->string, $start, $length) : substr($this->string, $start);
210 
211  return new self($string);
212  }
TeamSpeak3_Helper_String::split (   $separator,
  $limit = 0 
)

Splits the string into substrings wherever $separator occurs.

Parameters
string$separator
integer$limit
Returns
array

Definition at line 221 of file String.php.

References count().

Referenced by TeamSpeak3_Adapter_ServerQuery_Event\__construct().

222  {
223  $parts = explode($separator, $this->string, ($limit) ? intval($limit) : $this->count());
224 
225  foreach($parts as $key => $val)
226  {
227  $parts[$key] = new self($val);
228  }
229 
230  return $parts;
231  }
TeamSpeak3_Helper_String::append (   $part)

Appends $part to the string.

Parameters
string$part
Returns
TeamSpeak3_Helper_String

Definition at line 239 of file String.php.

240  {
241  $this->string = $this->string . strval($part);
242 
243  return $this;
244  }
TeamSpeak3_Helper_String::prepend (   $part)

Prepends $part to the string.

Parameters
string$part
Returns
TeamSpeak3_Helper_String

Definition at line 252 of file String.php.

253  {
254  $this->string = strval($part) . $this->string;
255 
256  return $this;
257  }
TeamSpeak3_Helper_String::section (   $separator,
  $first = 0,
  $last = 0 
)

Returns a section of the string.

Parameters
string$separator
integer$first
integer$last
Returns
TeamSpeak3_Helper_String

Definition at line 267 of file String.php.

References count().

Referenced by TeamSpeak3_Adapter_ServerQuery\request(), and TeamSpeak3_Adapter_ServerQuery\wait().

268  {
269  $sections = explode($separator, $this->string);
270 
271  $total = count($sections);
272  $first = intval($first);
273  $last = intval($last);
274 
275  if($first > $total) return null;
276  if($first > $last) $last = $first;
277 
278  for($i = 0; $i < $total; $i++)
279  {
280  if($i < $first || $i > $last)
281  {
282  unset($sections[$i]);
283  }
284  }
285 
286  $string = implode($separator, $sections);
287 
288  return new self($string);
289  }
TeamSpeak3_Helper_String::resize (   $size,
  $char = "\0" 
)

Sets the size of the string to $size characters.

Parameters
integer$size
string$char
Returns
TeamSpeak3_Helper_String

Definition at line 298 of file String.php.

References count(), and substr().

299  {
300  $chars = ($size - $this->count());
301 
302  if($chars < 0)
303  {
304  $this->string = substr($this->string, 0, $chars);
305  }
306  elseif($chars > 0)
307  {
308  $this->string = str_pad($this->string, $size, strval($char));
309  }
310 
311  return $this;
312  }
TeamSpeak3_Helper_String::trim ( )

Strips whitespaces (or other characters) from the beginning and end of the string.

Returns
TeamSpeak3_Helper_String

Definition at line 319 of file String.php.

Referenced by uriSafe().

320  {
321  $this->string = trim($this->string);
322 
323  return $this;
324  }
TeamSpeak3_Helper_String::escape ( )

Escapes a string using the TeamSpeak 3 escape patterns.

Returns
TeamSpeak3_Helper_String

Definition at line 331 of file String.php.

References TeamSpeak3\getEscapePatterns().

332  {
333  foreach(TeamSpeak3::getEscapePatterns() as $search => $replace)
334  {
335  $this->string = str_replace($search, $replace, $this->string);
336  }
337 
338  return $this;
339  }
TeamSpeak3_Helper_String::unescape ( )

Unescapes a string using the TeamSpeak 3 escape patterns.

Returns
TeamSpeak3_Helper_String

Definition at line 346 of file String.php.

References TeamSpeak3\getEscapePatterns().

347  {
348  $this->string = strtr($this->string, array_flip(TeamSpeak3::getEscapePatterns()));
349 
350  return $this;
351  }
TeamSpeak3_Helper_String::filterAlnum ( )

Removes any non alphanumeric characters from the string.

Returns
TeamSpeak3_Helper_String

Definition at line 358 of file String.php.

359  {
360  $this->string = preg_replace("/[^[:alnum:]]/", "", $this->string);
361 
362  return $this;
363  }
TeamSpeak3_Helper_String::filterAlpha ( )

Removes any non alphabetic characters from the string.

Returns
TeamSpeak3_Helper_String

Definition at line 370 of file String.php.

371  {
372  $this->string = preg_replace("/[^[:alpha:]]/", "", $this->string);
373 
374  return $this;
375  }
TeamSpeak3_Helper_String::filterDigits ( )

Removes any non numeric characters from the string.

Returns
TeamSpeak3_Helper_String

Definition at line 382 of file String.php.

383  {
384  $this->string = preg_replace("/[^[:digit:]]/", "", $this->string);
385 
386  return $this;
387  }
TeamSpeak3_Helper_String::isInt ( )

Returns TRUE if the string is a numeric value.

Returns
boolean

Definition at line 394 of file String.php.

References contains().

395  {
396  return (is_numeric($this->string) && !$this->contains(".")) ? TRUE : FALSE;
397  }
TeamSpeak3_Helper_String::toInt ( )

Returns the integer value of the string.

Returns
float
integer

Definition at line 405 of file String.php.

406  {
407  if($this->string == pow(2, 63) || $this->string == pow(2, 64))
408  {
409  return -1;
410  }
411 
412  return ($this->string > pow(2, 31)) ? floatval($this->string) : intval($this->string);
413  }
TeamSpeak3_Helper_String::toCrc32 ( )

Calculates and returns the crc32 polynomial of the string.

Returns
string

Definition at line 420 of file String.php.

421  {
422  return crc32($this->string);
423  }
TeamSpeak3_Helper_String::toMd5 ( )

Calculates and returns the md5 checksum of the string.

Returns
string

Definition at line 430 of file String.php.

431  {
432  return md5($this->string);
433  }
TeamSpeak3_Helper_String::toSha1 ( )

Calculates and returns the sha1 checksum of the string.

Returns
string

Definition at line 440 of file String.php.

441  {
442  return sha1($this->string);
443  }
TeamSpeak3_Helper_String::isUtf8 ( )

Returns TRUE if the string is UTF-8 encoded.

This method searches for non-ascii multibyte sequences in the UTF-8 range.

Returns
boolean

Definition at line 451 of file String.php.

Referenced by toUtf8().

452  {
453  $pattern = array();
454 
455  $pattern[] = "[\xC2-\xDF][\x80-\xBF]"; // non-overlong 2-byte
456  $pattern[] = "\xE0[\xA0-\xBF][\x80-\xBF]"; // excluding overlongs
457  $pattern[] = "[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}"; // straight 3-byte
458  $pattern[] = "\xED[\x80-\x9F][\x80-\xBF]"; // excluding surrogates
459  $pattern[] = "\xF0[\x90-\xBF][\x80-\xBF]{2}"; // planes 1-3
460  $pattern[] = "[\xF1-\xF3][\x80-\xBF]{3}"; // planes 4-15
461  $pattern[] = "\xF4[\x80-\x8F][\x80-\xBF]{2}"; // plane 16
462 
463  return preg_match("%(?:" . implode("|", $pattern) . ")+%xs", $this->string);
464  }
TeamSpeak3_Helper_String::toUtf8 ( )

Converts the string to UTF-8.

Returns
TeamSpeak3_Helper_String

Definition at line 471 of file String.php.

References isUtf8().

Referenced by transliterate().

472  {
473  if(!$this->isUtf8())
474  {
475  $this->string = utf8_encode($this->string);
476  }
477 
478  return $this;
479  }
TeamSpeak3_Helper_String::toBase64 ( )

Encodes the string with MIME base64 and returns the result.

Returns
string

Definition at line 486 of file String.php.

487  {
488  return base64_encode($this->string);
489  }
static TeamSpeak3_Helper_String::fromBase64 (   $base64)
static

Decodes the string with MIME base64 and returns the result as an TeamSpeak3_Helper_String.

Parameters
string
Returns
TeamSpeak3_Helper_String

Definition at line 497 of file String.php.

Referenced by TeamSpeak3_Node_Server\snapshotDeploy().

498  {
499  return new self(base64_decode($base64));
500  }
TeamSpeak3_Helper_String::toHex ( )

Returns the hexadecimal value of the string.

Returns
string

Definition at line 507 of file String.php.

508  {
509  $hex = "";
510 
511  foreach($this as $char)
512  {
513  $hex .= $char->toHex();
514  }
515 
516  return $hex;
517  }
static TeamSpeak3_Helper_String::fromHex (   $hex)
static

Returns the TeamSpeak3_Helper_String based on a given hex value.

Parameters
string
Exceptions
TeamSpeak3_Helper_Exception
Returns
TeamSpeak3_Helper_String

Definition at line 526 of file String.php.

Referenced by TeamSpeak3_Node_Server\snapshotDeploy(), and TeamSpeak3_Adapter_Update\syn().

527  {
528  $string = "";
529 
530  if(strlen($hex)%2 == 1)
531  {
532  throw new TeamSpeak3_Helper_Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
533  }
534 
535  foreach(str_split($hex, 2) as $chunk)
536  {
537  $string .= chr(hexdec($chunk));
538  }
539 
540  return new self($string);
541  }
TeamSpeak3_Helper_String::transliterate ( )

Returns the string transliterated from UTF-8 to Latin.

Returns
TeamSpeak3_Helper_String

Definition at line 548 of file String.php.

References toUtf8().

Referenced by uriSafe().

549  {
550  $utf8_accents = array(
551  "à" => "a",
552  "ô" => "o",
553  "Ä?" => "d",
554  "ḟ" => "f",
555  "ë" => "e",
556  "Å¡" => "s",
557  "Æ¡" => "o",
558  "ß" => "ss",
559  "ă" => "a",
560  "Å™" => "r",
561  "È›" => "t",
562  "ň" => "n",
563  "Ä?" => "a",
564  "Ä·" => "k",
565  "Å?" => "s",
566  "ỳ" => "y",
567  "ņ" => "n",
568  "ĺ" => "l",
569  "ħ" => "h",
570  "á¹—" => "p",
571  "ó" => "o",
572  "ú" => "u",
573  "Ä›" => "e",
574  "é" => "e",
575  "ç" => "c",
576  "áº?" => "w",
577  "Ä‹" => "c",
578  "õ" => "o",
579  "ṡ" => "s",
580  "ø" => "o",
581  "Ä£" => "g",
582  "ŧ" => "t",
583  "È™" => "s",
584  "Ä—" => "e",
585  "ĉ" => "c",
586  "Å›" => "s",
587  "î" => "i",
588  "ű" => "u",
589  "ć" => "c",
590  "Ä™" => "e",
591  "ŵ" => "w",
592  "ṫ" => "t",
593  "Å«" => "u",
594  "Ä?" => "c",
595  "ö" => "oe",
596  "è" => "e",
597  "Å·" => "y",
598  "Ä…" => "a",
599  "Å‚" => "l",
600  "ų" => "u",
601  "ů" => "u",
602  "ÅŸ" => "s",
603  "ÄŸ" => "g",
604  "ļ" => "l",
605  "Æ’" => "f",
606  "ž" => "z",
607  "ẃ" => "w",
608  "ḃ" => "b",
609  "Ã¥" => "a",
610  "ì" => "i",
611  "ï" => "i",
612  "ḋ" => "d",
613  "Å¥" => "t",
614  "Å—" => "r",
615  "ä" => "ae",
616  "í" => "i",
617  "Å•" => "r",
618  "ê" => "e",
619  "ü" => "ue",
620  "ò" => "o",
621  "Ä“" => "e",
622  "ñ" => "n",
623  "Å„" => "n",
624  "Ä¥" => "h",
625  "Ä?" => "g",
626  "Ä‘" => "d",
627  "ĵ" => "j",
628  "ÿ" => "y",
629  "Å©" => "u",
630  "Å­" => "u",
631  "ư" => "u",
632  "Å£" => "t",
633  "ý" => "y",
634  "Å‘" => "o",
635  "â" => "a",
636  "ľ" => "l",
637  "ẅ" => "w",
638  "ż" => "z",
639  "Ä«" => "i",
640  "ã" => "a",
641  "Ä¡" => "g",
642  "á¹?" => "m",
643  "Å?" => "o",
644  "Ä©" => "i",
645  "ù" => "u",
646  "į" => "i",
647  "ź" => "z",
648  "á" => "a",
649  "û" => "u",
650  "þ" => "th",
651  "ð" => "dh",
652  "æ" => "ae",
653  "µ" => "u",
654  "Ä•" => "e",
655  "Å“" => "oe",
656  "À" => "A",
657  "Ô" => "O",
658  "ÄŽ" => "D",
659  "Ḟ" => "F",
660  "Ë" => "E",
661  "Å " => "S",
662  "Æ " => "O",
663  "Ä‚" => "A",
664  "Ř" => "R",
665  "Èš" => "T",
666  "Ň" => "N",
667  "Ä€" => "A",
668  "Ķ" => "K",
669  "Åœ" => "S",
670  "Ỳ" => "Y",
671  "Å…" => "N",
672  "Ĺ" => "L",
673  "Ħ" => "H",
674  "á¹–" => "P",
675  "Ó" => "O",
676  "Ú" => "U",
677  "Äš" => "E",
678  "É" => "E",
679  "Ç" => "C",
680  "Ẁ" => "W",
681  "ÄŠ" => "C",
682  "Õ" => "O",
683  "á¹ " => "S",
684  "Ø" => "O",
685  "Ä¢" => "G",
686  "Ŧ" => "T",
687  "Ș" => "S",
688  "Ä–" => "E",
689  "Ĉ" => "C",
690  "Åš" => "S",
691  "ÃŽ" => "I",
692  "Ű" => "U",
693  "Ć" => "C",
694  "Ę" => "E",
695  "Å´" => "W",
696  "Ṫ" => "T",
697  "Ū" => "U",
698  "ÄŒ" => "C",
699  "Ö" => "Oe",
700  "È" => "E",
701  "Ŷ" => "Y",
702  "Ä„" => "A",
703  "Å?" => "L",
704  "Ų" => "U",
705  "Å®" => "U",
706  "Åž" => "S",
707  "Äž" => "G",
708  "Ä»" => "L",
709  "Æ‘" => "F",
710  "Ž" => "Z",
711  "Ẃ" => "W",
712  "Ḃ" => "B",
713  "Ã…" => "A",
714  "ÃŒ" => "I",
715  "Ã?" => "I",
716  "Ḋ" => "D",
717  "Ť" => "T",
718  "Å–" => "R",
719  "Ä" => "Ae",
720  "Ã?" => "I",
721  "Å”" => "R",
722  "Ê" => "E",
723  "Ü" => "Ue",
724  "Ã’" => "O",
725  "Ä’" => "E",
726  "Ñ" => "N",
727  "Ń" => "N",
728  "Ĥ" => "H",
729  "Äœ" => "G",
730  "Ä?" => "D",
731  "Ä´" => "J",
732  "Ÿ" => "Y",
733  "Ũ" => "U",
734  "Ŭ" => "U",
735  "Ư" => "U",
736  "Å¢" => "T",
737  "Ã?" => "Y",
738  "Å?" => "O",
739  "Â" => "A",
740  "Ľ" => "L",
741  "Ẅ" => "W",
742  "Å»" => "Z",
743  "Ī" => "I",
744  "Ã" => "A",
745  "Ä " => "G",
746  "á¹€" => "M",
747  "ÅŒ" => "O",
748  "Ĩ" => "I",
749  "Ù" => "U",
750  "Ä®" => "I",
751  "Ź" => "Z",
752  "Ã?" => "A",
753  "Û" => "U",
754  "Þ" => "Th",
755  "Ã?" => "Dh",
756  "Æ" => "Ae",
757  "Ä”" => "E",
758  "Å’" => "Oe",
759  );
760 
761  return new self($this->toUtf8()->replace(array_keys($utf8_accents), array_values($utf8_accents)));
762  }
TeamSpeak3_Helper_String::uriSafe (   $spacer = "-")

Processes the string and replaces all accented UTF-8 characters by unaccented ASCII-7 "equivalents", whitespaces are replaced by a pre-defined spacer and the string is lowercase.

Parameters
string$spacer
Returns
TeamSpeak3_Helper_String

Definition at line 771 of file String.php.

References transliterate(), and trim().

772  {
773  $this->string = str_replace($spacer, " ", $this->string);
774  $this->string = $this->transliterate();
775  $this->string = preg_replace("/(\s|[^A-Za-z0-9\-])+/", $spacer, trim(strtolower($this->string)));
776  $this->string = trim($this->string, $spacer);
777 
778  return new self($this->string);
779  }
TeamSpeak3_Helper_String::spaceToPercent ( )

Replaces space characters with percent encoded strings.

Returns
string

Definition at line 786 of file String.php.

787  {
788  return str_replace(" ", "%20", $this->string);
789  }
TeamSpeak3_Helper_String::toString ( )

Returns the string as a standard string.

Returns
string

Definition at line 796 of file String.php.

797  {
798  return $this->string;
799  }
TeamSpeak3_Helper_String::__call (   $function,
  $args 
)

Magical function that allows you to call PHP's built-in string functions on the TeamSpeak3_Helper_String object.

Parameters
string$function
array$args
Exceptions
TeamSpeak3_Helper_Exception
Returns
TeamSpeak3_Helper_String

Definition at line 809 of file String.php.

References count().

810  {
811  if(!function_exists($function))
812  {
813  throw new TeamSpeak3_Helper_Exception("cannot call undefined function '" . $function . "' on this object");
814  }
815 
816  if(count($args))
817  {
818  if(($key = array_search($this, $args, TRUE)) !== FALSE)
819  {
820  $args[$key] = $this->string;
821  }
822  else
823  {
824  throw new TeamSpeak3_Helper_Exception("cannot call undefined function '" . $function . "' without the " . __CLASS__ . " object parameter");
825  }
826 
827  $return = call_user_func_array($function, $args);
828  }
829  else
830  {
831  $return = call_user_func($function, $this->string);
832  }
833 
834  if(is_string($return))
835  {
836  $this->string = $return;
837  }
838  else
839  {
840  return $return;
841  }
842 
843  return $this;
844  }
TeamSpeak3_Helper_String::__toString ( )

Returns the character as a standard string.

Returns
string

Definition at line 851 of file String.php.

852  {
853  return (string) $this->string;
854  }
TeamSpeak3_Helper_String::count ( )

Definition at line 859 of file String.php.

Referenced by __call(), resize(), section(), split(), and valid().

860  {
861  return strlen($this->string);
862  }
TeamSpeak3_Helper_String::rewind ( )

Definition at line 867 of file String.php.

868  {
869  $this->position = 0;
870  }
TeamSpeak3_Helper_String::valid ( )

Definition at line 875 of file String.php.

References count().

876  {
877  return $this->position < $this->count();
878  }
TeamSpeak3_Helper_String::key ( )

Definition at line 883 of file String.php.

References $position.

884  {
885  return $this->position;
886  }
TeamSpeak3_Helper_String::current ( )

Definition at line 891 of file String.php.

892  {
893  return new TeamSpeak3_Helper_Char($this->string{$this->position});
894  }
TeamSpeak3_Helper_String::next ( )

Definition at line 899 of file String.php.

900  {
901  $this->position++;
902  }
TeamSpeak3_Helper_String::offsetExists (   $offset)

Definition at line 907 of file String.php.

Referenced by offsetGet(), offsetSet(), and offsetUnset().

908  {
909  return ($offset < strlen($this->string)) ? TRUE : FALSE;
910  }
TeamSpeak3_Helper_String::offsetGet (   $offset)

Definition at line 915 of file String.php.

References offsetExists().

916  {
917  return ($this->offsetExists($offset)) ? new TeamSpeak3_Helper_Char($this->string{$offset}) : null;
918  }
TeamSpeak3_Helper_String::offsetSet (   $offset,
  $value 
)

Definition at line 923 of file String.php.

References offsetExists().

924  {
925  if(!$this->offsetExists($offset)) return;
926 
927  $this->string{$offset} = strval($value);
928  }
TeamSpeak3_Helper_String::offsetUnset (   $offset)

Definition at line 933 of file String.php.

References offsetExists().

934  {
935  if(!$this->offsetExists($offset)) return;
936 
937  $this->string = substr_replace($this->string, "", $offset, 1);
938  }

Member Data Documentation

TeamSpeak3_Helper_String::$position = 0
protected

Definition at line 44 of file String.php.

Referenced by key().


The documentation for this class was generated from the following file: