public function send(string $method, array $params)
{
// Start profiling
$this->profileStart();
try {
// Fetch response
$response = $this->process('text/xml', xmlrpc_encode_request($method, $params, $this->options));
// Process response
$response = xmlrpc_decode($response, 'utf-8');
} catch (\Jyxo\Rpc\Exception $e) {
// Finish profiling
$this->profileEnd('XML', $method, $params, $e->getMessage());
throw new Exception($e->getMessage(), 0, $e);
}
// Finish profiling
$this->profileEnd('XML', $method, $params, $response);
// Error in response
if (is_array($response) && isset($response['faultString'])) {
throw new Exception(preg_replace('~\\s+~', ' ', $response['faultString']));
}
return $response;
}