\Phergie\IrcParserInterface

Parses strings containing messages conforming to those in the IRC protocol as described in RFC 1459.

Summary

Methods
Constants
parse()
parseAll()
consume()
consumeAll()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

parse()

parse(string $message) : array|null

Parses data for a single IRC message from a given string into an array with a structure similar to the following:

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

String containing the message to parse

Returns

array|null —

Associative array containing parsed data if a

    message is successfully parsed, null otherwise

parseAll()

parseAll(string $message) : array

Parses all available data for one or more IRC messages from a given string in the same way parse() does and returns an enumerated array of associative arrays each conforming to structure of the return value of parse().

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

Parses data for a single IRC message from a given string in the same way parse() does except that $message is passed by reference and the message parsed from it is removed afterward.

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

Parses all available data for one or more IRC messages from a given string in the same way consume() does and returns an enumerated array of associative arrays each conforming to structure of the return value of parse().

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