XMLEncoder
XMLEncoder
XML-RPC encoder implementation.
class XMLEncoder implements \Hazaar\RPC\Encoder\EncoderProvides methods for encoding and decoding XML-RPC requests, responses, and fault messages. Handles conversion between PHP types and XML-RPC-compliant XML structures.
Properties
outputOptions
Summary of outputOptions.
private array $outputOptionsMethods
__construct
Initializes a new instance of the Encoder class with optional output options.
public __construct(array $outputOptions): voidParameters
| Parameter | Type | Description |
|---|---|---|
$outputOptions | array | An associative array of output options to configure the XML output. Supported options are: - 'version': The XML version to use in the declaration (e.g., "1.0") - 'encoding': The character encoding to use in the declaration (e.g., "utf-8") - 'openTag': The string to use for opening tags (default is "<") - 'closeTag': The string to use for closing tags (default is ">") - 'newline': A string used for new lines (e.g., "\n") |
getContentType
Returns the MIME content type for XML data.
public getContentType(): stringrequest
Creates a new XML-RPC request element.
public request(string $method, array $params, mixed $requestID): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$method | string | the name of the method to be called |
$params | array | Optional. The parameters to pass to the method. |
$requestID | mixed |
response
Generates an XML-RPC method response element containing the given result.
public response(mixed $result, mixed $requestID): ElementParameters
| Parameter | Type | Description |
|---|---|---|
$result | mixed | the result value to be included in the response |
$requestID | mixed |
parse
Parses the given XML-RPC request element and returns an array representation.
public parse(string $xml, ?string $method, mixed $requestID): voidParameters
| Parameter | Type | Description |
|---|---|---|
$xml | string | the XML string of the request to be parsed |
$method | string | Optional. A variable to store the method name extracted from the request, if available. |
$requestID | mixed |
error
Creates an XML-RPC fault response element.
public error(\Throwable $throwable, mixed $requestID): ElementThis static method constructs an XML structure representing a fault response according to the XML-RPC specification. It includes the provided fault code and fault message in the appropriate XML format.
Parameters
| Parameter | Type | Description |
|---|---|---|
$throwable | \Throwable | |
$requestID | mixed |
encodeResponse
Encodes the given response into an XML response.
public encodeResponse(mixed $response): ResponseParameters
| Parameter | Type | Description |
|---|---|---|
$response | mixed | The response to encode. Must be an instance of Hazaar\XML\Element. |
encodeValue
Encodes a PHP value into an XML-RPC-compliant XML element.
private encodeValue(mixed $value): ElementSupports int, string, bool, float, indexed arrays, and associative arrays.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | the value to encode |
decodeValue
Decodes an XML-RPC-compliant XML element into a PHP value.
private decodeValue(Element $element): mixedSupports int, string, bool, float, indexed arrays, and associative arrays.
Parameters
| Parameter | Type | Description |
|---|---|---|
$element | Element | the XML element to decode |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000