TeamSpeak 3 PHP Framework  1.1.16
Copyright © Planet TeamSpeak. All rights reserved.
 All Classes Namespaces Files Functions Variables Pages
Handler.php
Go to the documentation of this file.
1 <?php
2 
3 /**
4  * @file
5  * TeamSpeak 3 PHP Framework
6  *
7  * $Id: Handler.php 8/31/2012 11:06:09 scp@orilla $
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @package TeamSpeak3
23  * @version 1.1.16
24  * @author Sven 'ScP' Paulsen
25  * @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
26  */
27 
28 /**
29  * @class TeamSpeak3_Helper_Signal_Handler
30  * @brief Helper class providing handler functions for signals.
31  */
33 {
34  /**
35  * Stores the name of the subscribed signal.
36  *
37  * @var string
38  */
39  protected $signal = null;
40 
41  /**
42  * Stores the callback function for the subscribed signal.
43  *
44  * @var mixed
45  */
46  protected $callback = null;
47 
48  /**
49  * The TeamSpeak3_Helper_Signal_Handler constructor.
50  *
51  * @param string $signal
52  * @param mixed $callback
53  * @throws TeamSpeak3_Helper_Signal_Exception
54  * @return TeamSpeak3_Helper_Signal_Handler
55  */
56  public function __construct($signal, $callback)
57  {
58  $this->signal = (string) $signal;
59 
60  if(!is_callable($callback))
61  {
62  throw new TeamSpeak3_Helper_Signal_Exception("invalid callback specified for signal '" . $signal . "'");
63  }
64 
65  $this->callback = $callback;
66  }
67 
68  /**
69  * Invoke the signal handler.
70  *
71  * @param array $args
72  * @return mixed
73  */
74  public function call(array $args = array())
75  {
76  return call_user_func_array($this->callback, $args);
77  }
78 }