Changeset 215 for trunk/Phergie/Event/Request.php
- Timestamp:
- 04/08/08 01:18:52 (8 months ago)
- Files:
-
- trunk/Phergie/Event/Request.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Event/Request.php
r204 r215 2 2 3 3 /** 4 * Autonomous event originating from a user or the server.5 *6 * @see http://www.irchelp.org/irchelp/rfc/chapter4.html7 */4 * Autonomous event originating from a user or the server. 5 * 6 * @see http://www.irchelp.org/irchelp/rfc/chapter4.html 7 */ 8 8 class Phergie_Event_Request 9 9 { 10 10 /** 11 * Nick message12 *13 * @const string14 */11 * Nick message 12 * 13 * @const string 14 */ 15 15 const TYPE_NICK = 'nick'; 16 16 17 17 /** 18 * Whois message19 *20 * @const string21 */18 * Whois message 19 * 20 * @const string 21 */ 22 22 const TYPE_WHOIS = 'whois'; 23 23 24 24 /** 25 * Quit command26 *27 * @const string28 */25 * Quit command 26 * 27 * @const string 28 */ 29 29 const TYPE_QUIT = 'quit'; 30 30 31 31 /** 32 * Join message33 *34 * @const string35 */32 * Join message 33 * 34 * @const string 35 */ 36 36 const TYPE_JOIN = 'join'; 37 37 38 38 /** 39 * Kick message40 *41 * @const string42 */39 * Kick message 40 * 41 * @const string 42 */ 43 43 const TYPE_KICK = 'kick'; 44 44 45 45 /** 46 * Part message47 *48 * @const string49 */46 * Part message 47 * 48 * @const string 49 */ 50 50 const TYPE_PART = 'part'; 51 51 52 52 /** 53 * Mode message54 *55 * @const string56 */53 * Mode message 54 * 55 * @const string 56 */ 57 57 const TYPE_MODE = 'mode'; 58 58 59 59 /** 60 * Topic message61 *62 * @const string63 */60 * Topic message 61 * 62 * @const string 63 */ 64 64 const TYPE_TOPIC = 'topic'; 65 65 66 66 /** 67 * Private message command68 *69 * @const string70 */67 * Private message command 68 * 69 * @const string 70 */ 71 71 const TYPE_PRIVMSG = 'privmsg'; 72 72 73 73 /** 74 * Notice message75 *76 * @const string77 */74 * Notice message 75 * 76 * @const string 77 */ 78 78 const TYPE_NOTICE = 'notice'; 79 79 80 80 /** 81 * Pong message82 *83 * @const string84 */81 * Pong message 82 * 83 * @const string 84 */ 85 85 const TYPE_PONG = 'pong'; 86 86 87 87 /** 88 * CTCP ACTION command89 *90 * @const string91 */88 * CTCP ACTION command 89 * 90 * @const string 91 */ 92 92 const TYPE_ACTION = 'action'; 93 93 94 94 /** 95 * RAW message96 *97 * @const string98 */95 * RAW message 96 * 97 * @const string 98 */ 99 99 const TYPE_RAW = 'raw'; 100 100 101 101 /** 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( 108 107 self::TYPE_QUIT => array( 109 108 'message' => 0 … … 159 158 160 159 /** 161 * Host name for the originating server or user162 *163 * @var string164 */160 * Host name for the originating server or user 161 * 162 * @var string 163 */ 165 164 protected $host; 166 165 167 166 /** 168 * Username of the user from which the event originates169 *170 * @var string171 */167 * Username of the user from which the event originates 168 * 169 * @var string 170 */ 172 171 protected $username; 173 172 174 173 /** 175 * Nick of the user from which the event originates176 *177 * @var string178 */174 * Nick of the user from which the event originates 175 * 176 * @var string 177 */ 179 178 protected $nick; 180 179 181 180 /** 182 * Request type, which can be compared to the TYPE_* constants183 *184 * @var string185 */181 * Request type, which can be compared to the TYPE_* constants 182 * 183 * @var string 184 */ 186 185 protected $type; 187 186 188 187 /** 189 * Arguments included with the message190 *191 * @var array192 */188 * Arguments included with the message 189 * 190 * @var array 191 */ 193 192 protected $arguments; 194 193 195 194 /** 196 * The raw buffer that was sent by the server197 *198 * @var string199 */195 * The raw buffer that was sent by the server 196 * 197 * @var string 198 */ 200 199 protected $rawBuffer; 201 200 202 201 /** 203 * Returns the hostmask for the originating server or user.204 *205 * @return string206 */202 * Returns the hostmask for the originating server or user. 203 * 204 * @return string 205 */ 207 206 public function getHostmask() 208 207 { … … 211 210 212 211 /** 213 * Sets the host name for the originating server or user.214 *215 * @param string $host216 * @return void217 */212 * Sets the host name for the originating server or user. 213 * 214 * @param string $host 215 * @return void 216 */ 218 217 public function setHost($host) 219 218 { … … 222 221 223 222 /** 224 * Returns the host name for the originating server or user.225 *226 * @return string227 */223 * Returns the host name for the originating server or user. 224 * 225 * @return string 226 */ 228 227 public function getHost() 229 228 { … … 232 231 233 232 /** 234 * Sets the username of the user from which the event originates.235 *236 * @param string $username237 * @return void238 */233 * Sets the username of the user from which the event originates. 234 * 235 * @param string $username 236 * @return void 237 */ 239 238 public function setUsername($username) 240 239 { … … 243 242 244 243 /** 245 * Returns the username of the user from which the event originates.246 *247 * @return string248 * @return void249 */244 * Returns the username of the user from which the event originates. 245 * 246 * @return string 247 * @return void 248 */ 250 249 public function getUsername() 251 250 { … … 254 253 255 254 /** 256 * Sets the nick of the user from which the event originates.257 *258 * @param string $nick259 * @return void260 */255 * Sets the nick of the user from which the event originates. 256 * 257 * @param string $nick 258 * @return void 259 */ 261 260 public function setNick($nick) 262 261 { … … 265 264 266 265 /** 267 * Returns the nick of the user from which the event originates.268 *269 * @return string270 * @return void271 */266 * Returns the nick of the user from which the event originates. 267 * 268 * @return string 269 * @return void 270 */ 272 271 public function getNick() 273 272 { … … 276 275 277 276 /** 278 * Sets the request type.279 *280 * @param string $type281 * @return void282 */277 * Sets the request type. 278 * 279 * @param string $type 280 * @return void 281 */ 283 282 public function setType($type) 284 283 { … … 287 286 288 287 /** 289 * Returns the request type, which can be compared to the TYPE_*290 * constants.291 *292 * @return string293 */288 * Returns the request type, which can be compared to the TYPE_* 289 * constants. 290 * 291 * @return string 292 */ 294 293 public function getType() 295 294 { … … 298 297 299 298 /** 300 * Sets the arguments for the request in the order they are to be sent.301 *302 * @param array $arguments303 * @return void304 */299 * Sets the arguments for the request in the order they are to be sent. 300 * 301 * @param array $arguments 302 * @return void 303 */ 305 304 public function setArguments($arguments) 306 305 { … … 309 308 310 309 /** 311 * Returns the arguments for the request in the order they are to be sent.312 *313 * @return array314 */310 * Returns the arguments for the request in the order they are to be sent. 311 * 312 * @return array 313 */ 315 314 public function getArguments() 316 315 { … … 319 318 320 319 /** 321 * Returns a single specified argument for the request.322 *323 * @param int $argument Position of the argument in the list, starting324 * from 0325 * @return string326 */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 */ 327 326 public function getArgument($argument) 328 327 { … … 331 330 } else { 332 331 $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]])) { 335 334 return $this->arguments[self::$map[$this->type][$argument]]; 336 335 } … … 340 339 341 340 /** 342 * Sets the raw buffer for the given event343 *344 * @param string $buffer345 * @return void346 */341 * Sets the raw buffer for the given event 342 * 343 * @param string $buffer 344 * @return void 345 */ 347 346 public function setRawBuffer($buffer) 348 347 { … … 351 350 352 351 /** 353 * Returns the raw buffer that was sent from the server for that event354 *355 * @return string356 */352 * Returns the raw buffer that was sent from the server for that event 353 * 354 * @return string 355 */ 357 356 public function getRawBuffer() 358 357 { … … 361 360 362 361 /** 363 * Returns the channel name or user nick representing the source of the364 * event.365 *366 * @return string367 */362 * Returns the channel name or user nick representing the source of the 363 * event. 364 * 365 * @return string 366 */ 368 367 public function getSource() 369 368 { … … 375 374 376 375 /** 377 * Returns whether or not the event occurred within a channel.378 *379 * @return TRUE if the event is in a channel, FALSE otherwise380 */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 */ 381 380 public function isInChannel() 382 381 { … … 385 384 386 385 /** 387 * Returns whether or not the event originated from a user.388 *389 * @return TRUE if the event is from a user, FALSE otherwise390 */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 */ 391 390 public function isFromUser() 392 391 { 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 otherwise400 */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 */ 401 400 public function isFromServer() 402 401 { … … 405 404 406 405 /** 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') { 418 416 return $this->getArgument(substr($name, 3)); 419 417 }