TeamSpeak 3 PHP Framework
Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances
TeamSpeak3_Helper_Char Class Reference

Helper class for char handling. More...

Public Member Functions

 __construct ($char)
 The TeamSpeak3_Helper_Char constructor. More...
 
 __toString ()
 Returns the character as a standard string. More...
 
 isControl ()
 Returns true if the character is a control character (i.e. More...
 
 isDigit ()
 Returns true if the character is a decimal digit. More...
 
 isLetter ()
 Returns true if the character is a letter. More...
 
 isLower ()
 Returns true if the character is a lowercase letter. More...
 
 isMark ()
 Returns true if the character is a mark. More...
 
 isNull ()
 Returns true if the character is the Unicode character 0x0000 ("\0"). More...
 
 isPrintable ()
 Returns true if the character is a printable character. More...
 
 isSpace ()
 Returns true if the character is a space. More...
 
 isUpper ()
 Returns true if the character is an uppercase letter. More...
 
 toAscii ()
 Returns the ascii value of the character. More...
 
 toHex ()
 Returns the hexadecimal value of the char. More...
 
 toInt ()
 Returns the integer value of the character. More...
 
 toLower ()
 Returns the lowercase equivalent if the character is uppercase. More...
 
 toString ()
 Returns the character as a standard string. More...
 
 toUnicode ()
 Returns the Unicode value of the character. More...
 
 toUpper ()
 Returns the uppercase equivalent if the character is lowercase. More...
 

Static Public Member Functions

static fromHex ($hex)
 Returns the TeamSpeak3_Helper_Char based on a given hex value. More...
 

Detailed Description

Helper class for char handling.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $char)

The TeamSpeak3_Helper_Char constructor.

Parameters
string$var
Exceptions
TeamSpeak3_Helper_Exception
Returns
TeamSpeak3_Helper_Char
46  {
47  if(strlen($char) != 1)
48  {
49  throw new TeamSpeak3_Helper_Exception("char parameter may not contain more or less than one character");
50  }
51 
52  $this->char = strval($char);
53  }
Enhanced exception class for TeamSpeak3_Helper_* objects.
Definition: Exception.php:29

Member Function Documentation

◆ __toString()

__toString ( )

Returns the character as a standard string.

Returns
string
263  {
264  return $this->char;
265  }

◆ fromHex()

static fromHex (   $hex)
static

Returns the TeamSpeak3_Helper_Char based on a given hex value.

Parameters
string$hex
Exceptions
TeamSpeak3_Helper_Exception
Returns
TeamSpeak3_Helper_Char
228  {
229  if(strlen($hex) != 2)
230  {
231  throw new TeamSpeak3_Helper_Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
232  }
233 
234  return new self(chr(hexdec($hex)));
235  }
Enhanced exception class for TeamSpeak3_Helper_* objects.
Definition: Exception.php:29

◆ isControl()

isControl ( )

Returns true if the character is a control character (i.e.

"\t").

Returns
boolean
101  {
102  return ctype_cntrl($this->char);
103  }

◆ isDigit()

isDigit ( )

Returns true if the character is a decimal digit.

Returns
boolean
71  {
72  return ctype_digit($this->char);
73  }

◆ isLetter()

isLetter ( )

Returns true if the character is a letter.

Returns
boolean
61  {
62  return ctype_alpha($this->char);
63  }

◆ isLower()

isLower ( )

Returns true if the character is a lowercase letter.

Returns
boolean
141  {
142  return ($this->char === strtolower($this->char)) ? TRUE : FALSE;
143  }

◆ isMark()

isMark ( )

Returns true if the character is a mark.

Returns
boolean
91  {
92  return ctype_punct($this->char);
93  }

◆ isNull()

isNull ( )

Returns true if the character is the Unicode character 0x0000 ("\0").

Returns
boolean
121  {
122  return ($this->char === "\0") ? TRUE : FALSE;
123  }

◆ isPrintable()

isPrintable ( )

Returns true if the character is a printable character.

Returns
boolean
111  {
112  return ctype_print($this->char);
113  }

◆ isSpace()

isSpace ( )

Returns true if the character is a space.

Returns
boolean
81  {
82  return ctype_space($this->char);
83  }

◆ isUpper()

isUpper ( )

Returns true if the character is an uppercase letter.

Returns
boolean
131  {
132  return ($this->char === strtoupper($this->char)) ? TRUE : FALSE;
133  }

◆ toAscii()

toAscii ( )

Returns the ascii value of the character.

Returns
integer
171  {
172  return ord($this->char);
173  }

◆ toHex()

toHex ( )

Returns the hexadecimal value of the char.

Returns
string
216  {
217  return strtoupper(dechex($this->toAscii()));
218  }
toAscii()
Returns the ascii value of the character.
Definition: Char.php:170

◆ toInt()

toInt ( )

Returns the integer value of the character.

Returns
integer
253  {
254  return intval($this->char);
255  }

◆ toLower()

toLower ( )

Returns the lowercase equivalent if the character is uppercase.

Returns
TeamSpeak3_Helper_Char
161  {
162  return ($this->isLower()) ? $this : new self(strtolower($this));
163  }
isLower()
Returns true if the character is a lowercase letter.
Definition: Char.php:140

◆ toString()

toString ( )

Returns the character as a standard string.

Returns
string
243  {
244  return $this->char;
245  }

◆ toUnicode()

toUnicode ( )

Returns the Unicode value of the character.

Returns
integer
181  {
182  $h = ord($this->char{0});
183 
184  if($h <= 0x7F)
185  {
186  return $h;
187  }
188  else if($h < 0xC2)
189  {
190  return FALSE;
191  }
192  else if($h <= 0xDF)
193  {
194  return ($h & 0x1F) << 6 | (ord($this->char{1}) & 0x3F);
195  }
196  else if($h <= 0xEF)
197  {
198  return ($h & 0x0F) << 12 | (ord($this->char{1}) & 0x3F) << 6 | (ord($this->char{2}) & 0x3F);
199  }
200  else if($h <= 0xF4)
201  {
202  return ($h & 0x0F) << 18 | (ord($this->char{1}) & 0x3F) << 12 | (ord($this->char{2}) & 0x3F) << 6 | (ord($this->char{3}) & 0x3F);
203  }
204  else
205  {
206  return FALSE;
207  }
208  }

◆ toUpper()

toUpper ( )

Returns the uppercase equivalent if the character is lowercase.

Returns
TeamSpeak3_Helper_Char
151  {
152  return ($this->isUpper()) ? $this : new self(strtoupper($this));
153  }
isUpper()
Returns true if the character is an uppercase letter.
Definition: Char.php:130

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