summaryrefslogtreecommitdiffstats
path: root/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php')
-rw-r--r--vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php
new file mode 100644
index 0000000..e2ce0ca
--- /dev/null
+++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace PayPalHttp\Serializer;
+
+use PayPalHttp\HttpRequest;
+use PayPalHttp\Serializer;
+
+/**
+ * Class Text
+ * @package PayPalHttp\Serializer
+ *
+ * Serializer for Text content types.
+ */
+class Text implements Serializer
+{
+
+ public function contentType()
+ {
+ return "/^text\\/.*/";
+ }
+
+ public function encode(HttpRequest $request)
+ {
+ $body = $request->body;
+ if (is_string($body)) {
+ return $body;
+ }
+ if (is_array($body)) {
+ return json_encode($body);
+ }
+ return implode(" ", $body);
+ }
+
+ public function decode($data)
+ {
+ return $data;
+ }
+}