public function call($method, array $arguments = [])
{
if ($this->value === null) {
return null;
} elseif (is_object($this->value)) {
$callback = [$this->value, $method];
} elseif (is_array($this->value)) {
if (!array_key_exists($method, $this->value)) {
throw new EvaluationException('Array has no function "' . $method . '"', 1344350459);
}
$callback = $this->value[$method];
} else {
throw new EvaluationException('Needs object or array to call method "' . $method . '", but has ' . gettype($this->value), 1344350454);
}
if (!is_callable($callback)) {
throw new EvaluationException('Method "' . $method . '" is not callable', 1344350374);
}
$argumentsCount = count($arguments);
for ($i = 0; $i < $argumentsCount; $i++) {
if ($arguments[$i] instanceof Context) {
$arguments[$i] = $arguments[$i]->unwrap();
}
}
return call_user_func_array($callback, $arguments);
}