Erebot  latest
A modular IRC bot for PHP 5.3+
Erebot\IrcCollator Class Reference

An abstract class that provides an IRC collation. More...

+ Inheritance diagram for Erebot\IrcCollator:

Public Member Functions

 compare ($a, $b)
 
 limitedCompare ($a, $b, $len)
 
 normalizeNick ($nick)
 

Protected Member Functions

 realNormalizeNick ($nick)
 

Detailed Description

An abstract class that provides an IRC collation.

Using subclasses of this class, you can compare two IRC nicknames.

Definition at line 30 of file IrcCollator.php.

Member Function Documentation

Erebot\IrcCollator::compare (   $a,
  $b 
)

Compares two string in a case-insensitive fashion (like strcasecmp).

Parameters
$aFirst string to compare.
$bSecond string to compare.
Return values
intAn integer less than, equal to or greater than zero if $a is found, respectively, to be less than, to match, or be greater than $b.

Implements Erebot\Interfaces\IrcCollator.

Definition at line 32 of file IrcCollator.php.

Erebot\IrcCollator::limitedCompare (   $a,
  $b,
  $len 
)

Compares two string in a case-insensitive fashion up to a given length (like strncasecmp).

Parameters
$aFirst string to compare.
$bSecond string to compare.
$lenLimit the comparison to only the first $len bytes of each string.
Return values
intAn integer less than, equal to or greater than zero if the first $len bytes of $a are found, respectively, to be less than, to match, or be greater than the first $len bytes of $b.

Implements Erebot\Interfaces\IrcCollator.

Definition at line 40 of file IrcCollator.php.

Erebot\IrcCollator::normalizeNick (   $nick)

Normalize (canonicalize) some IRC nickname.

This method can be used to compare two IRC nicknames like this:

if ($conn->normalizeNick($nick1) == $conn->normalizeNick($nick2)) {
// The two nicknames are considered equal.
}
Parameters
string$nickThe nickname to canonicalize.
Return values
stringA canonical representation of the nickname.
Warning
Make sure you use the same collation when comparing two nicknames or the result may be unpredictable.

Implements Erebot\Interfaces\IrcCollator.

Definition at line 49 of file IrcCollator.php.

Erebot\IrcCollator::realNormalizeNick (   $nick)
protected

Normalize (canonicalize) some IRC nickname.

This method can be used to compare two IRC nicknames like this:

if ($conn->normalizeNick($nick1) == $conn->normalizeNick($nick2)) {
// The two nicknames are considered equal.
}
Parameters
string$nickThe nickname to canonicalize.
Return values
stringA canonical representation of the nickname.
Warning
Make sure you use the same collation when comparing two nicknames or the result may be unpredictable.
Note
This method must be redefined in subclasses.

Definition at line 71 of file IrcCollator.php.


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