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