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