/** * @param $vars * @param $template * * @return bool|string */ private function _to_application_form_url_encoded($vars, $template = '') { $query_vars = $this->vars; foreach ($query_vars as $name => $value) { /** * @var array $matches Get all URL path var matches into an array */ preg_match_all('#([^{]+)\\{([^}]+)\\}#', $this->service->path, $matches); $path_vars = array_flip($matches[2]); if (isset($path_vars[$name])) { $var = $this->client->get_var($name); $value = $var->apply_transforms($value); $template = str_replace("{{$name}}", $value, $template); unset($query_vars[$name]); } } $result = http_build_query($query_vars); return $result; }