From b039b173d8d53fd2fcd75a1df7259ccf1f2005f7 Mon Sep 17 00:00:00 2001 From: Juraj Date: Tue, 16 Jan 2018 16:42:40 +0100 Subject: [PATCH] Allow base64/binary values to support binary data Usage e.g.: php_xmlrpc_encode(file_get_contents(...), ['base64']) php_xmlrpc_encode(file_get_contents(...), ['binary']) --- src/Encoder.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Encoder.php b/src/Encoder.php index 735c3edc..5d4cc71e 100644 --- a/src/Encoder.php +++ b/src/Encoder.php @@ -136,7 +136,11 @@ public function encode($phpVal, $options = array()) $type = gettype($phpVal); switch ($type) { case 'string': - if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $phpVal)) { + if (in_array('binary', $options)) { + $xmlrpcVal = new Value($phpVal, Value::$xmlrpcBinary); + } elseif (in_array('base64', $options)) { + $xmlrpcVal = new Value($phpVal, Value::$xmlrpcBase64); + } elseif (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $phpVal)) { $xmlrpcVal = new Value($phpVal, Value::$xmlrpcDateTime); } else { $xmlrpcVal = new Value($phpVal, Value::$xmlrpcString);