PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.1
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / vendor / paypal / paypalhttp / lib / PayPalHttp / Serializer / Json.php

Json.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.1, at vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php

39 lines 711 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PayPalHttp\Serializer;
4
5 use PayPalHttp\HttpRequest;
6 use PayPalHttp\Serializer;
7
8 /**
9 * Class Json
10 * @package PayPalHttp\Serializer
11 *
12 * Serializer for JSON content types.
13 */
14 class Json implements Serializer
15 {
16
17 public function contentType()
18 {
19 return "/^application\\/json/";
20 }
21
22 public function encode(HttpRequest $request)
23 {
24 $body = $request->body;
25 if (is_string($body)) {
26 return $body;
27 }
28 if (is_array($body)) {
29 return json_encode($body);
30 }
31 throw new \Exception("Cannot serialize data. Unknown type");
32 }
33
34 public function decode($data)
35 {
36 return json_decode($data);
37 }
38 }
39