XMLEncoder
XMLEncoder
XML-RPC encoder implementation.
class XMLEncoder implements \Hazaar\RPC\Interface\EncoderImplements: Hazaar\RPC\Interface\Encoder
Provides 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 $outputOptionsType: array
Methods
__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(): stringReturns: string
request
Creates a new XML-RPC request element.
public request(string $method, array $params, null|int|string $requestID): ElementReturns: Hazaar\XML\Element
Parameters
| Parameter | Type | Description |
|---|---|---|
$method | string | the name of the method to be called |
$params | array | Optional. The parameters to pass to the method. |
$requestID | null | int |
response
Generates an XML-RPC method response element containing the given result.
public response(mixed $result, null|int|string $requestID): ElementReturns: Hazaar\XML\Element
Parameters
| Parameter | Type | Description |
|---|---|---|
$result | mixed | the result value to be included in the response |
$requestID | null | int |
parse
Parses the given XML-RPC request element and returns an array representation.
public parse(string $xml, ?string $method, null|int|string $requestID): arrayReturns: array
Parameters
| 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 | null | int |
error
Creates an XML-RPC fault response element.
public error(\Throwable $throwable, null|int|string $requestID): ElementReturns: Hazaar\XML\Element
This 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 | null | int |
encodeResponse
Encodes the given response into an XML response.
public encodeResponse(mixed $response): ResponseReturns: Hazaar\Controller\Response
Parameters
| 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): ElementReturns: Hazaar\XML\Element
Supports 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): mixedReturns: mixed
Supports int, string, bool, float, indexed arrays, and associative arrays.
Parameters
| Parameter | Type | Description |
|---|---|---|
$element | Hazaar\XML\Element | the XML element to decode |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000