ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
XML_RPC2_Backend_Php_Value_Scalar Class Reference
+ Inheritance diagram for XML_RPC2_Backend_Php_Value_Scalar:
+ Collaboration diagram for XML_RPC2_Backend_Php_Value_Scalar:

Public Member Functions

 getScalarType ()
 scalarType property getter More...
 
 __construct ($scalarType, $nativeValue)
 Constructor. More...
 
 encode ()
 Encode the instance into XML, for transport. More...
 
- Public Member Functions inherited from XML_RPC2_Backend_Php_Value
 getNativeValue ()
 nativeValue property getter More...
 

Static Public Member Functions

static createFromNative ($nativeValue, $explicitType=null)
 Choose a XML_RPC2_Value subclass appropriate for the given value and create it. More...
 
- Static Public Member Functions inherited from XML_RPC2_Backend_Php_Value
static createFromNative ($nativeValue, $explicitType=null)
 Choose a XML_RPC2_Value subclass appropriate for the given value and create it. More...
 
static createFromDecode ($simpleXML)
 Decode an encoded value and build the applicable XML_RPC2_Value subclass. More...
 
- Static Public Member Functions inherited from XML_RPC2_Value
static createFromNative ($value, $explicitType=null)
 Factory method that constructs the appropriate XML-RPC encoded type value. More...
 

Protected Member Functions

 setScalarType ($value)
 scalarType property setter More...
 
- Protected Member Functions inherited from XML_RPC2_Backend_Php_Value
 setNativeValue ($value)
 nativeValue setter More...
 

Private Attributes

 $_scalarType = null
 

Detailed Description

Definition at line 57 of file Scalar.php.

Constructor & Destructor Documentation

◆ __construct()

XML_RPC2_Backend_Php_Value_Scalar::__construct (   $scalarType,
  $nativeValue 
)

Constructor.

Will build a new XML_RPC2_Value_Scalar with the given nativeValue

Parameters
mixednativeValue

Definition at line 115 of file Scalar.php.

References XML_RPC2_Backend_Php_Value\setNativeValue(), and setScalarType().

116  {
117  $this->setScalarType($scalarType);
118  $this->setNativeValue($nativeValue);
119  }
setScalarType($value)
scalarType property setter
Definition: Scalar.php:77
setNativeValue($value)
nativeValue setter
Definition: Value.php:89
+ Here is the call graph for this function:

Member Function Documentation

◆ createFromNative()

static XML_RPC2_Backend_Php_Value_Scalar::createFromNative (   $nativeValue,
  $explicitType = null 
)
static

Choose a XML_RPC2_Value subclass appropriate for the given value and create it.

Parameters
stringThe native value
stringOptinally, the scalar type to use
Exceptions
XML_RPC2_InvalidTypeEncodeExceptionWhen native value's type is not a native type
Returns
XML_RPC2_Value The newly created value

Definition at line 133 of file Scalar.php.

Referenced by XML_RPC2_Backend_Php_Value\createFromNative().

134  {
135  if (is_null($explicitType)) {
136  switch (gettype($nativeValue)) {
137  case 'boolean':
138  case 'integer':
139  case 'double':
140  case 'string':
141  $explicitType = gettype($nativeValue);
142  break;
143  default:
144  throw new XML_RPC2_InvalidTypeEncodeException(sprintf('Impossible to encode scalar value \'%s\' from type \'%s\'. Native type is not a scalar XML_RPC type (boolean, integer, double, string)',
145  (string) $nativeValue,
146  gettype($nativeValue)));
147  }
148  }
149  $explicitType = ucfirst(strtolower($explicitType));
150  require_once(sprintf('XML/RPC2/Backend/Php/Value/%s.php', $explicitType));
151  $explicitType = sprintf('XML_RPC2_Backend_Php_Value_%s', $explicitType);
152  return new $explicitType($nativeValue);
153  }
+ Here is the caller graph for this function:

◆ encode()

XML_RPC2_Backend_Php_Value_Scalar::encode ( )

Encode the instance into XML, for transport.

Returns
string The encoded XML-RPC value,

Definition at line 163 of file Scalar.php.

References XML_RPC2_Backend_Php_Value\getNativeValue(), and getScalarType().

164  {
165  return '<' . $this->getScalarType() . '>' . $this->getNativeValue() . '</' . $this->getScalarType() . '>';
166  }
getScalarType()
scalarType property getter
Definition: Scalar.php:102
getNativeValue()
nativeValue property getter
Definition: Value.php:76
+ Here is the call graph for this function:

◆ getScalarType()

XML_RPC2_Backend_Php_Value_Scalar::getScalarType ( )

scalarType property getter

Returns
mixed The current scalarType

Definition at line 102 of file Scalar.php.

References $_scalarType.

Referenced by encode().

103  {
104  return $this->_scalarType;
105  }
+ Here is the caller graph for this function:

◆ setScalarType()

XML_RPC2_Backend_Php_Value_Scalar::setScalarType (   $value)
protected

scalarType property setter

Parameters
mixedvalue The new scalarType

Definition at line 77 of file Scalar.php.

Referenced by XML_RPC2_Backend_Php_Value_Integer\__construct(), XML_RPC2_Backend_Php_Value_String\__construct(), XML_RPC2_Backend_Php_Value_Double\__construct(), and __construct().

78  {
79  switch ($value) {
80  case 'int':
81  case 'i4':
82  case 'boolean':
83  case 'string':
84  case 'double':
85  case 'dateTime.iso8601':
86  case 'base64':
87  $this->_scalarType = $value;
88  break;
89  default:
90  throw new XML_RPC2_InvalidTypeException(sprintf('Type \'%s\' is not an XML-RPC scalar type', $value));
91  }
92  }
+ Here is the caller graph for this function:

Field Documentation

◆ $_scalarType

XML_RPC2_Backend_Php_Value_Scalar::$_scalarType = null
private

Definition at line 67 of file Scalar.php.

Referenced by getScalarType().


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