Add PhpDoc headers to all components
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / Callback.class.php
1 <?php
2
3 namespace wcf\system;
4
5 use wcf\system\exception\SystemException;
6
7 /**
8 * Represents a callback
9 *
10 * @author Tim Duesterhus
11 * @copyright 2001-2019 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @deprecated since 3.0, use callables and `callable` type hint directly
14 */
15 final class Callback
16 {
17 /**
18 * encapsulated callback
19 * @var callback
20 */
21 private $callback;
22
23 /**
24 * Creates new instance of Callback.
25 *
26 * @param callback $callback
27 * @throws SystemException
28 */
29 public function __construct($callback)
30 {
31 if (!\is_callable($callback)) {
32 throw new SystemException('Given callback is not callable.');
33 }
34
35 $this->callback = $callback;
36 }
37
38 /**
39 * Invokes our callback. All parameters are simply passed through.
40 *
41 * @return mixed
42 */
43 public function __invoke()
44 {
45 return \call_user_func_array($this->callback, \func_get_args());
46 }
47 }