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

Helper class for char handling. More...

Public Member Functions

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

Static Public Member Functions

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

Protected Attributes

 $char = null
 

Detailed Description

Helper class for char handling.

Definition at line 32 of file Char.php.

Constructor & Destructor Documentation

TeamSpeak3_Helper_Char::__construct (   $char)

The TeamSpeak3_Helper_Char constructor.

Parameters
string$var
Exceptions
TeamSpeak3_Helper_Exception
Returns
TeamSpeak3_Helper_Char

Definition at line 48 of file Char.php.

{
if(strlen($char) != 1)
{
throw new TeamSpeak3_Helper_Exception("char parameter may not contain more or less than one character");
}
$this->char = strval($char);
}

Member Function Documentation

TeamSpeak3_Helper_Char::isLetter ( )

Returns true if the character is a letter.

Returns
boolean

Definition at line 63 of file Char.php.

{
return ctype_alpha($this->char);
}
TeamSpeak3_Helper_Char::isDigit ( )

Returns true if the character is a decimal digit.

Returns
boolean

Definition at line 73 of file Char.php.

{
return ctype_digit($this->char);
}
TeamSpeak3_Helper_Char::isSpace ( )

Returns true if the character is a space.

Returns
boolean

Definition at line 83 of file Char.php.

{
return ctype_space($this->char);
}
TeamSpeak3_Helper_Char::isMark ( )

Returns true if the character is a mark.

Returns
boolean

Definition at line 93 of file Char.php.

{
return ctype_punct($this->char);
}
TeamSpeak3_Helper_Char::isControl ( )

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

"\t").

Returns
boolean

Definition at line 103 of file Char.php.

{
return ctype_cntrl($this->char);
}
TeamSpeak3_Helper_Char::isPrintable ( )

Returns true if the character is a printable character.

Returns
boolean

Definition at line 113 of file Char.php.

{
return ctype_print($this->char);
}
TeamSpeak3_Helper_Char::isNull ( )

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

Returns
boolean

Definition at line 123 of file Char.php.

{
return ($this->char === "\0") ? TRUE : FALSE;
}
TeamSpeak3_Helper_Char::isUpper ( )

Returns true if the character is an uppercase letter.

Returns
boolean

Definition at line 133 of file Char.php.

Referenced by toUpper().

{
return ($this->char === strtoupper($this->char)) ? TRUE : FALSE;
}
TeamSpeak3_Helper_Char::isLower ( )

Returns true if the character is a lowercase letter.

Returns
boolean

Definition at line 143 of file Char.php.

Referenced by toLower().

{
return ($this->char === strtolower($this->char)) ? TRUE : FALSE;
}
TeamSpeak3_Helper_Char::toUpper ( )

Returns the uppercase equivalent if the character is lowercase.

Returns
TeamSpeak3_Helper_Char

Definition at line 153 of file Char.php.

References isUpper().

{
return ($this->isUpper()) ? $this : new self(strtoupper($this));
}
TeamSpeak3_Helper_Char::toLower ( )

Returns the lowercase equivalent if the character is uppercase.

Returns
TeamSpeak3_Helper_Char

Definition at line 163 of file Char.php.

References isLower().

{
return ($this->isLower()) ? $this : new self(strtolower($this));
}
TeamSpeak3_Helper_Char::toAscii ( )

Returns the ascii value of the character.

Returns
integer

Definition at line 173 of file Char.php.

Referenced by toHex().

{
return ord($this->char);
}
TeamSpeak3_Helper_Char::toUnicode ( )

Returns the Unicode value of the character.

Returns
integer

Definition at line 183 of file Char.php.

{
$h = ord($this->char{0});
if($h <= 0x7F)
{
return $h;
}
else if($h < 0xC2)
{
return FALSE;
}
else if($h <= 0xDF)
{
return ($h & 0x1F) << 6 | (ord($this->char{1}) & 0x3F);
}
else if($h <= 0xEF)
{
return ($h & 0x0F) << 12 | (ord($this->char{1}) & 0x3F) << 6 | (ord($this->char{2}) & 0x3F);
}
else if($h <= 0xF4)
{
return ($h & 0x0F) << 18 | (ord($this->char{1}) & 0x3F) << 12 | (ord($this->char{2}) & 0x3F) << 6 | (ord($this->char{3}) & 0x3F);
}
else
{
return FALSE;
}
}
TeamSpeak3_Helper_Char::toHex ( )

Returns the hexadecimal value of the char.

Returns
string

Definition at line 218 of file Char.php.

References toAscii().

{
return strtoupper(dechex($this->toAscii()));
}
static TeamSpeak3_Helper_Char::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

Definition at line 230 of file Char.php.

{
if(strlen($hex) != 2)
{
throw new TeamSpeak3_Helper_Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
}
return new self(chr(hexdec($hex)));
}
TeamSpeak3_Helper_Char::toString ( )

Returns the character as a standard string.

Returns
string

Definition at line 245 of file Char.php.

{
return $this->char;
}
TeamSpeak3_Helper_Char::toInt ( )

Returns the integer value of the character.

Returns
integer

Definition at line 255 of file Char.php.

{
return intval($this->char);
}
TeamSpeak3_Helper_Char::__toString ( )

Returns the character as a standard string.

Returns
string

Definition at line 265 of file Char.php.

{
return $this->char;
}

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