TeamSpeak 3 PHP Framework  1.1.12
TeamSpeak3_Helper_Char Class Reference

Helper class for char handling. More...

List of all members.

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

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

Returns true if the character is a letter.

Returns:
boolean

Definition at line 63 of file Char.php.

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

Returns true if the character is a decimal digit.

Returns:
boolean

Definition at line 73 of file Char.php.

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

Returns true if the character is a space.

Returns:
boolean

Definition at line 83 of file Char.php.

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

Returns true if the character is a mark.

Returns:
boolean

Definition at line 93 of file Char.php.

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

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);
  }

Returns true if the character is a printable character.

Returns:
boolean

Definition at line 113 of file Char.php.

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

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;
  }

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;
  }

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;
  }

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));
  }

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));
  }

Returns the ascii value of the character.

Returns:
integer

Definition at line 173 of file Char.php.

Referenced by toHex().

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

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;
    }
  }

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)));
  }

Returns the character as a standard string.

Returns:
string

Definition at line 245 of file Char.php.

  {
    return $this->char;
  }

Returns the integer value of the character.

Returns:
integer

Definition at line 255 of file Char.php.

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

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:
 All Classes Files Functions Variables