1 | <?php |
||
9 | class UqlFunction implements \JsonSerializable, UqlFunctionInterface |
||
10 | { |
||
11 | /** |
||
12 | * Instance to which this function/method belongs |
||
13 | * |
||
14 | * @var UqlExtensionInterface |
||
15 | */ |
||
16 | private $instance; |
||
17 | |||
18 | /** |
||
19 | * Name of the method in the instance where its defined |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $method; |
||
24 | |||
25 | /** |
||
26 | * Name by which this function will be known inside UQL |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | private $name; |
||
31 | |||
32 | /** |
||
33 | * @param string $name |
||
34 | * @param UqlExtensionInterface $instance |
||
35 | * @param string $method |
||
36 | */ |
||
37 | public function __construct($name, UqlExtensionInterface $instance, $method) |
||
43 | |||
44 | /** |
||
45 | * @return UqlExtensionInterface |
||
46 | */ |
||
47 | public function getInstance() |
||
51 | |||
52 | /** |
||
53 | * @return mixed |
||
54 | */ |
||
55 | public function getMethod() |
||
59 | |||
60 | /** |
||
61 | * @return mixed |
||
62 | */ |
||
63 | public function getName() |
||
64 | { |
||
65 | return $this->name; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Performs the call to the function defined by this FunctionExtension |
||
70 | * |
||
71 | * @param array $arguments |
||
72 | * |
||
73 | * @return mixed |
||
74 | */ |
||
75 | public function call($arguments) |
||
76 | { |
||
77 | return call_user_func_array([$this->getInstance(), $this->getMethod()], $arguments); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Returns a readable string representation of the function, of the standard form: |
||
82 | * |
||
83 | * functionName(argument1, argument2, [optionalArgument1 = defaultValue, [optionalNullableArgument2]]) |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | public function __toString() |
||
115 | |||
116 | /** |
||
117 | * (PHP 5 >= 5.4.0)<br/> |
||
118 | * Specify data which should be serialized to JSON |
||
119 | * |
||
120 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
121 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
122 | * which is a value of any type other than a resource. |
||
123 | */ |
||
124 | public function jsonSerialize() |
||
158 | } |
||
159 |