TeamSpeak 3 PHP Framework  1.1.12
libraries/TeamSpeak3/Helper/Signal/Handler.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /**
00004  * @file
00005  * TeamSpeak 3 PHP Framework
00006  *
00007  * $Id: Handler.php 2/18/2012 12:42:46 scp@orilla $
00008  *
00009  * This program is free software: you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation, either version 3 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00021  *
00022  * @package   TeamSpeak3
00023  * @version   1.1.12
00024  * @author    Sven 'ScP' Paulsen
00025  * @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
00026  */
00027 
00028 /**
00029  * @class TeamSpeak3_Helper_Signal_Handler
00030  * @brief Helper class providing handler functions for signals.
00031  */
00032 class TeamSpeak3_Helper_Signal_Handler
00033 {
00034   /**
00035    * Stores the name of the subscribed signal.
00036    *
00037    * @var string
00038    */
00039   protected $signal = null;
00040 
00041   /**
00042    * Stores the callback function for the subscribed signal.
00043    *
00044    * @var mixed
00045    */
00046   protected $callback = null;
00047 
00048   /**
00049    * The TeamSpeak3_Helper_Signal_Handler constructor.
00050    *
00051    * @param  string $signal
00052    * @param  mixed  $callback
00053    * @throws TeamSpeak3_Helper_Signal_Exception
00054    * @return TeamSpeak3_Helper_Signal_Handler
00055    */
00056   public function __construct($signal, $callback)
00057   {
00058     $this->signal = (string) $signal;
00059 
00060     if(!is_callable($callback))
00061     {
00062       throw new TeamSpeak3_Helper_Signal_Exception("invalid callback specified for signal '" . $signal . "'");
00063     }
00064 
00065     $this->callback = $callback;
00066   }
00067 
00068   /**
00069    * Invoke the signal handler.
00070    *
00071    * @param  array $args
00072    * @return mixed
00073    */
00074   public function call(array $args = array())
00075   {
00076     return call_user_func_array($this->callback, $args);
00077   }
00078 }
 All Classes Files Functions Variables