Erebot  latest
A modular IRC bot for PHP 7.0+
Erebot\Identity Class Reference

Represents the identity of an IRC user. More...

+ Inheritance diagram for Erebot\Identity:

Public Member Functions

 __construct ($user)
 __toString ()
 getHost ($c10n)
 getIdent ()
 getMask ($c10n)
 getNick ()
 match ($pattern,\Erebot\Interfaces\IrcCollator $collator)

Static Protected Member Functions

static canonicalizeHost ($host, $c10n, $uncompressed)
static patternize ($pattern, $matchDot)
static stripLeading (&$number, $key)

Protected Attributes

 Host part for this user identity, either a string or null.
 Identity string for this user identity, either a string or null.
 Nickname for this user identity, either a string or null.

Detailed Description

Represents the identity of an IRC user.

Definition at line 27 of file Identity.php.

Constructor & Destructor Documentation

Erebot\Identity::__construct (   $user)

Creates a new object holding some user's identity.

string$userA string, representing some user. This can be either a mask, such as "foo!ident@host" or just a nickname, such as "foo".
Erebot::InvalidValueExceptionThe given $user does not represent a valid identity.

Definition at line 49 of file Identity.php.

Member Function Documentation

static Erebot\Identity::canonicalizeHost (   $host,

Canonicalizes a host.

Despite its name, this method may be applied to either a hostname or an IP address (v4 or v6).

string$hostHostname or IP address to canonicalize.
opaque$c10nThe type of canonicalization to apply. This is either Erebot::Interfaces::Identity::CANON_IPV4 or Erebot::Interfaces::Identity::CANON_IPV6 depending on whether IPv6-mapped-IPv4 addresses should be rendered in dotted form or in the regular IPv6 form, respectively.
bool$uncompressedWhether to compress IP addresses or not. In compressed form, leading zeros in a colon group are omitted and a series of groups with all-zeros is represented with just "::".
Return values
stringThe original hostname or IP address in canonicalized (and optionally compressed) form.
The only transformation that is applied to hostnames as part of this canonicalization method is one that lowercases them.
See Also
See the various RFCs related to IP addresses for an exact description of the transformations that apply when compressing an IPv6 address.

Definition at line 165 of file Identity.php.

Erebot\Identity::match (   $pattern,
\Erebot\Interfaces\IrcCollator  $collator 

Indicates whether this identity matches a given pattern.

string$patternThe pattern this identity should be tested against. The '?' and '*' wildcard characters are supported.
Erebot::Interfaces::IrcCollator$collatorCollator object to use to compare IRC nicknames.
Return values
booltrue if this identity matches the given pattern, false otherwise.

Definition at line 326 of file Identity.php.

static Erebot\Identity::patternize (   $pattern,

Turn a basic pattern (optionally) containing wirldcards into a regular expression pattern, intended to match hostnames or IP addresses.

string$patternBasic pattern, possibly containing wildcard characters ('*' and '?').
bool$matchDotWhether the '?' and '*' wildcard characters should also match dots '.' (true) or not (false).
Return values
stringA regular expression pattern that matches the criteria expressed in the original pattern.

Definition at line 457 of file Identity.php.

static Erebot\Identity::stripLeading ( $number,

Strips leading '0' in front of a numeric string.

string$numberNumeric string whose leading '0' should be stripped. Passed by reference and modified in-place.
Nothing ($number is modified in-place).
This method is meant to be used with the array_walk() PHP function.

Definition at line 122 of file Identity.php.

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