\Phergie\IrcParser

Canonical implementation of ParserInterface.

Summary

Methods
Properties
Constants
__construct()
parse()
parseAll()
consume()
consumeAll()
No public properties found
No constants found
strip()
removeIntegerKeys()
$message
$target
$channel
$ctcp
$ctcpParams
$params
$replies
N/A
No private methods found
No private properties found
N/A

Properties

$message

$message : string

Regular expression to match a single IRC message

Type

string

$target

$target : string

Regular expression to parse target information from the first parameter of a single IRC message

Type

string

$channel

$channel : string

Regular expression to parse channel names

Type

string

$ctcp

$ctcp : string

Regular expression to parse CTCP commands

Type

string

$ctcpParams

$ctcpParams : array

Mapping of CTCP commands to corresponding regular expressions for parsing parameter values for those commands

Type

array

$params

$params : array

Mapping of IRC commands to corresponding regular expressions for parsing parameter values for those commands

Type

array

$replies

$replies : array

Mapping of numeric replies to their descriptive codes

Type

array

Methods

__construct()

__construct()

Constructs regular expressions used to parse messages.

parse()

parse(string $message) : array|null

Implements ParserInterface::parse().

array(

'prefix' => ':Angel',
'nick' => 'Angel',
'command' => 'USER',
'params' => array(
    'username' => 'guest',
    'hostname' => 'tolmoon',
    'servername' => 'tolsun',
    'realname' => 'Ronnie Regan',
    'all' => 'guest tolmoon tolsun :Ronnie Regan',
),
'targets' => array('guest'),
'message' => "USER guest tolmoon tolsun :Ronnie Regan\r\n",
'tail' => 'NICK :Wiz',

),

The prefix and its components and individual targets as described in Section 2.3.1 of RFC 1459 are referenced by the 'prefix' and 'targets' keys, respectively. A string containing the first full parsed message is referenced by the 'message' key. Any remaining data after the first message is referenced by the 'tail' key. The command and its parameters are referenced by the 'command' and 'params' keys, respectively. Keys used for parameters follow the naming conventions described in Section 4 of RFC 1459. See unit tests for Phergie\Irc\Parser for examples.

Parameters

string $message

Data stream containing the message to parse

Returns

array|null —

Associative array containing parsed data if the

    message is successfully parsed, null otherwise

parseAll()

parseAll(string $message) : array

Implements ParserInterface::parseAll().

Parameters

string $message

String containing the message to parse

Returns

array —

Enumerated array of associative arrays each containing

    parsed data for a single message if any messages are
    successfully parsed, an empty array otherwise

consume()

consume(string $message) : array|null

Implements ParserInterface::consume().

Parameters

string $message

String containing the message to parse

Returns

array|null —

Associative array containing parsed data if a

    message is successfully parsed, null otherwise

consumeAll()

consumeAll(string $message) : array

Implements ParserInterface::consumeAll().

Parameters

string $message

String containing the message to parse

Returns

array —

Enumerated array of associative arrays each containing

    parsed data for a single message if any messages are
    successfully parsed, an empty array otherwise

strip()

strip(string $param) : string

Strips leading space and colon from a given parameter string.

Parameters

string $param

Returns

string

removeIntegerKeys()

removeIntegerKeys(array $array) : array

Removes elements with numeric keys from an array.

Parameters

array $array

Returns

array