Assembla home | Assembla project page
 
Show
Ignore:
Timestamp:
04/08/08 01:18:52 (8 months ago)
Author:
Slynderdale
Message:

Cleaned up the code and beautified it. Fixed all the indentation and went with a unified code format.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Event/Request.php

    r204 r215  
    22 
    33/** 
    4 * Autonomous event originating from a user or the server. 
    5 
    6 * @see http://www.irchelp.org/irchelp/rfc/chapter4.html 
    7 */ 
     4 * Autonomous event originating from a user or the server. 
     5
     6 * @see http://www.irchelp.org/irchelp/rfc/chapter4.html 
     7 */ 
    88class Phergie_Event_Request 
    99{ 
    1010    /** 
    11     * Nick message 
    12    
    13     * @const string 
    14     */ 
     11    * Nick message 
     12   
     13    * @const string 
     14    */ 
    1515    const TYPE_NICK = 'nick'; 
    1616 
    1717    /** 
    18     * Whois message 
    19    
    20     * @const string 
    21     */ 
     18    * Whois message 
     19   
     20    * @const string 
     21    */ 
    2222    const TYPE_WHOIS = 'whois'; 
    2323 
    2424    /** 
    25     * Quit command 
    26    
    27     * @const string 
    28     */ 
     25    * Quit command 
     26   
     27    * @const string 
     28    */ 
    2929    const TYPE_QUIT = 'quit'; 
    3030 
    3131    /** 
    32     * Join message 
    33    
    34     * @const string 
    35     */ 
     32    * Join message 
     33   
     34    * @const string 
     35    */ 
    3636    const TYPE_JOIN = 'join'; 
    3737 
    3838    /** 
    39     * Kick message 
    40    
    41     * @const string 
    42     */ 
     39    * Kick message 
     40   
     41    * @const string 
     42    */ 
    4343    const TYPE_KICK = 'kick'; 
    4444 
    4545    /** 
    46     * Part message 
    47    
    48     * @const string 
    49     */ 
     46    * Part message 
     47   
     48    * @const string 
     49    */ 
    5050    const TYPE_PART = 'part'; 
    5151 
    5252    /** 
    53     * Mode message 
    54    
    55     * @const string 
    56     */ 
     53    * Mode message 
     54   
     55    * @const string 
     56    */ 
    5757    const TYPE_MODE = 'mode'; 
    5858 
    5959    /** 
    60     * Topic message 
    61    
    62     * @const string 
    63     */ 
     60    * Topic message 
     61   
     62    * @const string 
     63    */ 
    6464    const TYPE_TOPIC = 'topic'; 
    6565 
    6666    /** 
    67     * Private message command 
    68    
    69     * @const string 
    70     */ 
     67    * Private message command 
     68   
     69    * @const string 
     70    */ 
    7171    const TYPE_PRIVMSG = 'privmsg'; 
    7272 
    7373    /** 
    74     * Notice message 
    75    
    76     * @const string 
    77     */ 
     74    * Notice message 
     75   
     76    * @const string 
     77    */ 
    7878    const TYPE_NOTICE = 'notice'; 
    7979 
    8080    /** 
    81     * Pong message 
    82    
    83     * @const string 
    84     */ 
     81    * Pong message 
     82   
     83    * @const string 
     84    */ 
    8585    const TYPE_PONG = 'pong'; 
    8686 
    8787    /** 
    88     * CTCP ACTION command 
    89    
    90     * @const string 
    91     */ 
     88    * CTCP ACTION command 
     89   
     90    * @const string 
     91    */ 
    9292    const TYPE_ACTION = 'action'; 
    9393 
    9494    /** 
    95     * RAW message 
    96    
    97     * @const string 
    98     */ 
     95    * RAW message 
     96   
     97    * @const string 
     98    */ 
    9999    const TYPE_RAW = 'raw'; 
    100100 
    101101    /** 
    102     * Mapping of event types to their named parameters 
    103     * 
    104     * @var array 
    105     */ 
    106     protected static $map = array 
    107     ( 
     102     * Mapping of event types to their named parameters 
     103     * 
     104     * @var array 
     105     */ 
     106    protected static $map = array( 
    108107        self::TYPE_QUIT => array( 
    109108            'message' => 0 
     
    159158 
    160159    /** 
    161     * Host name for the originating server or user 
    162    
    163     * @var string 
    164     */ 
     160    * Host name for the originating server or user 
     161   
     162    * @var string 
     163    */ 
    165164    protected $host; 
    166165 
    167166    /** 
    168     * Username of the user from which the event originates 
    169    
    170     * @var string 
    171     */ 
     167    * Username of the user from which the event originates 
     168   
     169    * @var string 
     170    */ 
    172171    protected $username; 
    173172 
    174173    /** 
    175     * Nick of the user from which the event originates 
    176    
    177     * @var string 
    178     */ 
     174    * Nick of the user from which the event originates 
     175   
     176    * @var string 
     177    */ 
    179178    protected $nick; 
    180179 
    181180    /** 
    182     * Request type, which can be compared to the TYPE_* constants 
    183    
    184     * @var string 
    185     */ 
     181    * Request type, which can be compared to the TYPE_* constants 
     182   
     183    * @var string 
     184    */ 
    186185    protected $type; 
    187186 
    188187    /** 
    189     * Arguments included with the message 
    190    
    191     * @var array 
    192     */ 
     188    * Arguments included with the message 
     189   
     190    * @var array 
     191    */ 
    193192    protected $arguments; 
    194193 
    195194    /** 
    196     * The raw buffer that was sent by the server 
    197    
    198     * @var string 
    199     */ 
     195    * The raw buffer that was sent by the server 
     196   
     197    * @var string 
     198    */ 
    200199    protected $rawBuffer; 
    201200 
    202201    /** 
    203     * Returns the hostmask for the originating server or user. 
    204    
    205     * @return string 
    206     */ 
     202    * Returns the hostmask for the originating server or user. 
     203   
     204    * @return string 
     205    */ 
    207206    public function getHostmask() 
    208207    { 
     
    211210 
    212211    /** 
    213     * Sets the host name for the originating server or user. 
    214    
    215     * @param string $host 
    216     * @return void 
    217     */ 
     212    * Sets the host name for the originating server or user. 
     213   
     214    * @param string $host 
     215    * @return void 
     216    */ 
    218217    public function setHost($host) 
    219218    { 
     
    222221 
    223222    /** 
    224     * Returns the host name for the originating server or user. 
    225    
    226     * @return string 
    227     */ 
     223    * Returns the host name for the originating server or user. 
     224   
     225    * @return string 
     226    */ 
    228227    public function getHost() 
    229228    { 
     
    232231 
    233232    /** 
    234     * Sets the username of the user from which the event originates. 
    235    
    236     * @param string $username 
    237     * @return void 
    238     */ 
     233    * Sets the username of the user from which the event originates. 
     234   
     235    * @param string $username 
     236    * @return void 
     237    */ 
    239238    public function setUsername($username) 
    240239    { 
     
    243242 
    244243    /** 
    245     * Returns the username of the user from which the event originates. 
    246    
    247     * @return string 
    248     * @return void 
    249     */ 
     244    * Returns the username of the user from which the event originates. 
     245   
     246    * @return string 
     247    * @return void 
     248    */ 
    250249    public function getUsername() 
    251250    { 
     
    254253 
    255254    /** 
    256     * Sets the nick of the user from which the event originates. 
    257    
    258     * @param string $nick 
    259     * @return void 
    260     */ 
     255    * Sets the nick of the user from which the event originates. 
     256   
     257    * @param string $nick 
     258    * @return void 
     259    */ 
    261260    public function setNick($nick) 
    262261    { 
     
    265264 
    266265    /** 
    267     * Returns the nick of the user from which the event originates. 
    268    
    269     * @return string 
    270     * @return void 
    271     */ 
     266    * Returns the nick of the user from which the event originates. 
     267   
     268    * @return string 
     269    * @return void 
     270    */ 
    272271    public function getNick() 
    273272    { 
     
    276275 
    277276    /** 
    278     * Sets the request type. 
    279    
    280     * @param string $type 
    281     * @return void 
    282     */ 
     277    * Sets the request type. 
     278   
     279    * @param string $type 
     280    * @return void 
     281    */ 
    283282    public function setType($type) 
    284283    { 
     
    287286 
    288287    /** 
    289     * Returns the request type, which can be compared to the TYPE_* 
    290     * constants. 
    291    
    292     * @return string 
    293     */ 
     288    * Returns the request type, which can be compared to the TYPE_* 
     289    * constants. 
     290   
     291    * @return string 
     292    */ 
    294293    public function getType() 
    295294    { 
     
    298297 
    299298    /** 
    300     * Sets the arguments for the request in the order they are to be sent. 
    301    
    302     * @param array $arguments 
    303     * @return void 
    304     */ 
     299    * Sets the arguments for the request in the order they are to be sent. 
     300   
     301    * @param array $arguments 
     302    * @return void 
     303    */ 
    305304    public function setArguments($arguments) 
    306305    { 
     
    309308 
    310309    /** 
    311     * Returns the arguments for the request in the order they are to be sent. 
    312    
    313     * @return array 
    314     */ 
     310    * Returns the arguments for the request in the order they are to be sent. 
     311   
     312    * @return array 
     313    */ 
    315314    public function getArguments() 
    316315    { 
     
    319318 
    320319    /** 
    321     * Returns a single specified argument for the request. 
    322    
    323     * @param int $argument Position of the argument in the list, starting 
    324     *                      from 0 
    325     * @return string 
    326     */ 
     320    * Returns a single specified argument for the request. 
     321   
     322    * @param int $argument Position of the argument in the list, starting 
     323    *                      from 0 
     324    * @return string 
     325    */ 
    327326    public function getArgument($argument) 
    328327    { 
     
    331330        } else { 
    332331            $argument = strtolower($argument); 
    333             if (isset(self::$map[$this->type][$argument]) 
    334                 && isset($this->arguments[self::$map[$this->type][$argument]])) { 
     332            if (isset(self::$map[$this->type][$argument]) && 
     333                isset($this->arguments[self::$map[$this->type][$argument]])) { 
    335334                return $this->arguments[self::$map[$this->type][$argument]]; 
    336335            } 
     
    340339 
    341340    /** 
    342     * Sets the raw buffer for the given event 
    343    
    344     * @param string $buffer 
    345     * @return void 
    346     */ 
     341    * Sets the raw buffer for the given event 
     342   
     343    * @param string $buffer 
     344    * @return void 
     345    */ 
    347346    public function setRawBuffer($buffer) 
    348347    { 
     
    351350 
    352351    /** 
    353     * Returns the raw buffer that was sent from the server for that event 
    354    
    355     * @return string 
    356     */ 
     352    * Returns the raw buffer that was sent from the server for that event 
     353   
     354    * @return string 
     355    */ 
    357356    public function getRawBuffer() 
    358357    { 
     
    361360 
    362361    /** 
    363     * Returns the channel name or user nick representing the source of the 
    364     * event. 
    365    
    366     * @return string 
    367     */ 
     362    * Returns the channel name or user nick representing the source of the 
     363    * event. 
     364   
     365    * @return string 
     366    */ 
    368367    public function getSource() 
    369368    { 
     
    375374 
    376375    /** 
    377     * Returns whether or not the event occurred within a channel. 
    378    
    379     * @return TRUE if the event is in a channel, FALSE otherwise 
    380     */ 
     376    * Returns whether or not the event occurred within a channel. 
     377   
     378    * @return TRUE if the event is in a channel, FALSE otherwise 
     379    */ 
    381380    public function isInChannel() 
    382381    { 
     
    385384 
    386385    /** 
    387     * Returns whether or not the event originated from a user. 
    388    
    389     * @return TRUE if the event is from a user, FALSE otherwise 
    390     */ 
     386    * Returns whether or not the event originated from a user. 
     387   
     388    * @return TRUE if the event is from a user, FALSE otherwise 
     389    */ 
    391390    public function isFromUser() 
    392391    { 
    393         return ! empty($this->username); 
    394     } 
    395  
    396     /** 
    397     * Returns whether or not the event originated from the server. 
    398    
    399     * @return TRUE if the event is from the server, FALSE otherwise 
    400     */ 
     392        return !empty($this->username); 
     393    } 
     394 
     395    /** 
     396    * Returns whether or not the event originated from the server. 
     397   
     398    * @return TRUE if the event is from the server, FALSE otherwise 
     399    */ 
    401400    public function isFromServer() 
    402401    { 
     
    405404 
    406405    /** 
    407     * Provides access to named parameters via virtual "getter" methods. 
    408     * 
    409     * @param string $name Name of the method called 
    410     * @param array $arguments Arguments passed to the method (should always 
    411     *                         be empty) 
    412     * @return mixed 
    413     */ 
    414     public function __call($name, array $arguments) 
    415     { 
    416         if (count($arguments) == 0 
    417             && substr($name, 0, 3) == 'get') { 
     406     * Provides access to named parameters via virtual "getter" methods. 
     407     * 
     408     * @param string $name Name of the method called 
     409     * @param array $arguments Arguments passed to the method (should always 
     410     *                         be empty) 
     411     * @return mixed 
     412     */ 
     413    public function __call($name, array$arguments) 
     414    { 
     415        if (count($arguments) == 0 && substr($name, 0, 3) == 'get') { 
    418416            return $this->getArgument(substr($name, 3)); 
    419417        }