XRL  latest
Simple XML-RPC Library (both client and server)
fpoirotte\XRL\NativeEncoder Class Reference

An XML-RPC encoder that transparently converts PHP types to their XML-RPC counterpart. More...

+ Inheritance diagram for fpoirotte\XRL\NativeEncoder:

Public Member Functions

 __construct (\fpoirotte\XRL\EncoderInterface $encoder)
 
 encodeError (\Exception $error)
 
 encodeRequest (\fpoirotte\XRL\Request $request)
 
 encodeResponse ($response)
 

Static Public Member Functions

static convert ($value)
 

Static Protected Member Functions

static isBinaryString ($text)
 
static isUTF8 ($text)
 

Protected Attributes

 $encoder
 Sub-encoder.
 

Detailed Description

An XML-RPC encoder that transparently converts PHP types to their XML-RPC counterpart.

Authors
François Poirotte click.nosp@m.y@er.nosp@m.ebot..nosp@m.net

Definition at line 21 of file NativeEncoder.php.

Constructor & Destructor Documentation

fpoirotte\XRL\NativeEncoder::__construct ( \fpoirotte\XRL\EncoderInterface  $encoder)

Creates a new encoder.

Parameters
fpoirotte::XRL::EncoderInterface$encoderSub-encoder to use.

Definition at line 32 of file NativeEncoder.php.

References fpoirotte\XRL\NativeEncoder\$encoder.

Member Function Documentation

static fpoirotte\XRL\NativeEncoder::convert (   $value)
static

Convert the given PHP value to an XML-RPC type.

Parameters
mixed$valueThe PHP value to convert.
Return values
fpoirotte::XRL::Types::AbstractTypeThe value encapsulated in an XML-RPC type.
Note
This implementation supports the "nil" XML-RPC extension (http://ontosys.com/xml-rpc/extensions.php).
An empty PHP array will always be encoded as an empty XML-RPC array.
The following PHP types are currently supported:
  • null (encoded using the "nil" XML-RPC type).
  • integer (encoded using the "i4" or "i8" XML-RPC type, depending on the actual size required to store the value).
  • boolean (encoded using the "boolean" XML-RPC type).
  • string (encoded using either the default type of XML-RPC [string] or "base64" if the string contains invalid UTF-8 sequences, such as when encoding binary data).
  • double (encoded using the "double" XML-RPC type).
  • array (encoded using either the "array" or "struct" XML-RPC type):
    • "array" is used for numerically-indexed arrays where the keys are in the range [0..len(array)-1], aka "lists".
    • "struct" is used for all other arrays, aka "hashes".
  • DateTime objects (encoded using the "dateTime.iso8601" XML-RPC type).
  • GMP objects/resources (encoded as "i4", "i8" or "BigInteger", depending on their actual storage size).
  • XML objects (SimpleXML, DOM and XMLWriter objects) are encoded as XML DOM fragments.
  • objects that support serialization (encoded as an XML-RPC "string" or "base64" type depending on the object's representation in serialized form).

Definition at line 258 of file NativeEncoder.php.

Referenced by fpoirotte\XRL\Encoder\encodeError().

fpoirotte\XRL\NativeEncoder::encodeError ( \Exception  $error)

Encode an exception as an XML-RPC failure.

Parameters
Exception$errorThe exception to encode.
Return values
stringThe exception, encoded as a XML-RPC failure in serialized form.

Implements fpoirotte\XRL\EncoderInterface.

Definition at line 365 of file NativeEncoder.php.

fpoirotte\XRL\NativeEncoder::encodeRequest ( \fpoirotte\XRL\Request  $request)

Encode an XML-RPC request.

Parameters
fpoirotte::XRL::Request$requestThe XML-RPC request to encode.
Return values
stringThe XML-RPC request, encoded as serialized XML.

Implements fpoirotte\XRL\EncoderInterface.

Definition at line 356 of file NativeEncoder.php.

fpoirotte\XRL\NativeEncoder::encodeResponse (   $response)

Encode an XML-RPC response.

Parameters
mixed$responseThe XML-RPC response to encode.
Return values
stringThe XML-RPC reponse, encoded as serialized XML.

Implements fpoirotte\XRL\EncoderInterface.

Definition at line 371 of file NativeEncoder.php.

static fpoirotte\XRL\NativeEncoder::isUTF8 (   $text)
staticprotected

Determine if a string contains a valid sequence of UTF-8 encoded Unicode codepoints.

Parameters
string$textSome text to test for UTF-8 validity.
Return values
booltrue if the $text contains a valid UTF-8 sequence which does not make use of non-characters/reserved characters, null if it contains a valid UTF-8 containing non-characters/reserved characters, or false otherwise.

Definition at line 50 of file NativeEncoder.php.


The documentation for this class was generated from the following file: