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