diff options
Diffstat (limited to '')
6 files changed, 310 insertions, 310 deletions
diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer.php index 2edcfe2..a3e88ad 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer.php @@ -1,29 +1,29 @@ -<?php - -namespace PayPalHttp; - -/** - * Interface Serializer - * @package PayPalHttp - * - * Used to implement different serializers for different content types - */ -interface Serializer -{ - /** - * @return string Regex that matches the content type it supports. - */ - public function contentType(); - - /** - * @param HttpRequest $request - * @return string representation of your data after being serialized. - */ - public function encode(HttpRequest $request); - - /** - * @param $body - * @return mixed object/string representing the de-serialized response body. - */ - public function decode($body); -} +<?php
+
+namespace PayPalHttp;
+
+/**
+ * Interface Serializer
+ * @package PayPalHttp
+ *
+ * Used to implement different serializers for different content types
+ */
+interface Serializer
+{
+ /**
+ * @return string Regex that matches the content type it supports.
+ */
+ public function contentType();
+
+ /**
+ * @param HttpRequest $request
+ * @return string representation of your data after being serialized.
+ */
+ public function encode(HttpRequest $request);
+
+ /**
+ * @param $body
+ * @return mixed object/string representing the de-serialized response body.
+ */
+ public function decode($body);
+}
diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Form.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Form.php index bead9d3..18aa064 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Form.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Form.php @@ -1,46 +1,46 @@ -<?php - -namespace PayPalHttp\Serializer; - -use PayPalHttp\HttpRequest; -use PayPalHttp\Serializer; - -class Form implements Serializer -{ - /** - * @return string Regex that matches the content type it supports. - */ - public function contentType() - { - return "/^application\/x-www-form-urlencoded$/"; - } - - /** - * @param HttpRequest $request - * @return string representation of your data after being serialized. - */ - public function encode(HttpRequest $request) - { - if (!is_array($request->body) || !$this->isAssociative($request->body)) - { - throw new \Exception("HttpRequest body must be an associative array when Content-Type is: " . $request->headers["Content-Type"]); - } - - return http_build_query($request->body); - } - - /** - * @param $body - * @return mixed - * @throws \Exception as multipart does not support deserialization. - */ - public function decode($body) - { - throw new \Exception("CurlSupported does not support deserialization"); - } - - private function isAssociative(array $array) - { - return array_values($array) !== $array; - } -} +<?php
+
+namespace PayPalHttp\Serializer;
+
+use PayPalHttp\HttpRequest;
+use PayPalHttp\Serializer;
+
+class Form implements Serializer
+{
+ /**
+ * @return string Regex that matches the content type it supports.
+ */
+ public function contentType()
+ {
+ return "/^application\/x-www-form-urlencoded$/";
+ }
+
+ /**
+ * @param HttpRequest $request
+ * @return string representation of your data after being serialized.
+ */
+ public function encode(HttpRequest $request)
+ {
+ if (!is_array($request->body) || !$this->isAssociative($request->body))
+ {
+ throw new \Exception("HttpRequest body must be an associative array when Content-Type is: " . $request->headers["Content-Type"]);
+ }
+
+ return http_build_query($request->body);
+ }
+
+ /**
+ * @param $body
+ * @return mixed
+ * @throws \Exception as multipart does not support deserialization.
+ */
+ public function decode($body)
+ {
+ throw new \Exception("CurlSupported does not support deserialization");
+ }
+
+ private function isAssociative(array $array)
+ {
+ return array_values($array) !== $array;
+ }
+}
diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/FormPart.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/FormPart.php index 3779a9b..5c40026 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/FormPart.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/FormPart.php @@ -1,25 +1,25 @@ -<?php - -namespace PayPalHttp\Serializer; - -class FormPart -{ - private $value; - private $headers; - - public function __construct($value, $headers) - { - $this->value = $value; - $this->headers = array_merge([], $headers); - } - - public function getValue() - { - return $this->value; - } - - public function getHeaders() - { - return $this->headers; - } -} +<?php
+
+namespace PayPalHttp\Serializer;
+
+class FormPart
+{
+ private $value;
+ private $headers;
+
+ public function __construct($value, $headers)
+ {
+ $this->value = $value;
+ $this->headers = array_merge([], $headers);
+ }
+
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ public function getHeaders()
+ {
+ return $this->headers;
+ }
+}
diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php index 3f66314..a73897c 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php @@ -1,38 +1,38 @@ -<?php - -namespace PayPalHttp\Serializer; - -use PayPalHttp\HttpRequest; -use PayPalHttp\Serializer; - -/** - * Class Json - * @package PayPalHttp\Serializer - * - * Serializer for JSON content types. - */ -class Json implements Serializer -{ - - public function contentType() - { - return "/^application\\/json/"; - } - - public function encode(HttpRequest $request) - { - $body = $request->body; - if (is_string($body)) { - return $body; - } - if (is_array($body)) { - return json_encode($body); - } - throw new \Exception("Cannot serialize data. Unknown type"); - } - - public function decode($data) - { - return json_decode($data); - } -} +<?php
+
+namespace PayPalHttp\Serializer;
+
+use PayPalHttp\HttpRequest;
+use PayPalHttp\Serializer;
+
+/**
+ * Class Json
+ * @package PayPalHttp\Serializer
+ *
+ * Serializer for JSON content types.
+ */
+class Json implements Serializer
+{
+
+ public function contentType()
+ {
+ return "/^application\\/json/";
+ }
+
+ public function encode(HttpRequest $request)
+ {
+ $body = $request->body;
+ if (is_string($body)) {
+ return $body;
+ }
+ if (is_array($body)) {
+ return json_encode($body);
+ }
+ throw new \Exception("Cannot serialize data. Unknown type");
+ }
+
+ public function decode($data)
+ {
+ return json_decode($data);
+ }
+}
diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Multipart.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Multipart.php index a420205..b9142de 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Multipart.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Multipart.php @@ -1,134 +1,134 @@ -<?php - -namespace PayPalHttp\Serializer; - -use finfo; -use PayPalHttp\HttpRequest; -use PayPalHttp\Serializer; -use PayPalHttp\Encoder; -use PayPalHttp\Serializer\FormPart; - -/** - * Class Multipart - * @package PayPalHttp\Serializer - * - * Serializer for multipart. - */ -class Multipart implements Serializer -{ - const LINEFEED = "\r\n"; - - public function contentType() - { - return "/^multipart\/.*$/"; - } - - public function encode(HttpRequest $request) - { - if (!is_array($request->body) || !$this->isAssociative($request->body)) - { - throw new \Exception("HttpRequest body must be an associative array when Content-Type is: " . $request->headers["content-type"]); - } - $boundary = "---------------------" . md5(mt_rand() . microtime()); - $contentTypeHeader = $request->headers["content-type"]; - $request->headers["content-type"] = "{$contentTypeHeader}; boundary={$boundary}"; - - $value_params = []; - $file_params = []; - - $disallow = ["\0", "\"", "\r", "\n"]; - - $body = []; - - foreach ($request->body as $k => $v) { - $k = str_replace($disallow, "_", $k); - if (is_resource($v)) { - $file_params[] = $this->prepareFilePart($k, $v, $boundary); - } else if ($v instanceof FormPart) { - $value_params[] = $this->prepareFormPart($k, $v, $boundary); - } else { - $value_params[] = $this->prepareFormField($k, $v, $boundary); - } - } - - $body = array_merge($value_params, $file_params); - - // add boundary for each parameters - array_walk($body, function (&$part) use ($boundary) { - $part = "--{$boundary}" . self::LINEFEED . "{$part}"; - }); - - // add final boundary - $body[] = "--{$boundary}--"; - $body[] = ""; - - return implode(self::LINEFEED, $body); - } - - public function decode($data) - { - throw new \Exception("Multipart does not support deserialization"); - } - - private function isAssociative(array $array) - { - return array_values($array) !== $array; - } - - private function prepareFormField($partName, $value, $boundary) - { - return implode(self::LINEFEED, [ - "Content-Disposition: form-data; name=\"{$partName}\"", - "", - filter_var($value), - ]); - } - - private function prepareFilePart($partName, $file, $boundary) - { - $fileInfo = new finfo(FILEINFO_MIME_TYPE); - $filePath = stream_get_meta_data($file)['uri']; - $data = file_get_contents($filePath); - $mimeType = $fileInfo->buffer($data); - - $splitFilePath = explode(DIRECTORY_SEPARATOR, $filePath); - $filePath = end($splitFilePath); - $disallow = ["\0", "\"", "\r", "\n"]; - $filePath = str_replace($disallow, "_", $filePath); - return implode(self::LINEFEED, [ - "Content-Disposition: form-data; name=\"{$partName}\"; filename=\"{$filePath}\"", - "Content-Type: {$mimeType}", - "", - $data, - ]); - } - - private function prepareFormPart($partName, $formPart, $boundary) - { - $contentDisposition = "Content-Disposition: form-data; name=\"{$partName}\""; - - $partHeaders = $formPart->getHeaders(); - $formattedheaders = array_change_key_case($partHeaders); - if (array_key_exists("content-type", $formattedheaders)) { - if ($formattedheaders["content-type"] === "application/json") { - $contentDisposition .= "; filename=\"{$partName}.json\""; - } - $tempRequest = new HttpRequest('/', 'POST'); - $tempRequest->headers = $formattedheaders; - $tempRequest->body = $formPart->getValue(); - $encoder = new Encoder(); - $partValue = $encoder->serializeRequest($tempRequest); - } else { - $partValue = $formPart->getValue(); - } - - $finalPartHeaders = []; - foreach ($partHeaders as $k => $v) { - $finalPartHeaders[] = "{$k}: {$v}"; - } - - $body = array_merge([$contentDisposition], $finalPartHeaders, [""], [$partValue]); - - return implode(self::LINEFEED, $body); - } -} +<?php
+
+namespace PayPalHttp\Serializer;
+
+use finfo;
+use PayPalHttp\HttpRequest;
+use PayPalHttp\Serializer;
+use PayPalHttp\Encoder;
+use PayPalHttp\Serializer\FormPart;
+
+/**
+ * Class Multipart
+ * @package PayPalHttp\Serializer
+ *
+ * Serializer for multipart.
+ */
+class Multipart implements Serializer
+{
+ const LINEFEED = "\r\n";
+
+ public function contentType()
+ {
+ return "/^multipart\/.*$/";
+ }
+
+ public function encode(HttpRequest $request)
+ {
+ if (!is_array($request->body) || !$this->isAssociative($request->body))
+ {
+ throw new \Exception("HttpRequest body must be an associative array when Content-Type is: " . $request->headers["content-type"]);
+ }
+ $boundary = "---------------------" . md5(mt_rand() . microtime());
+ $contentTypeHeader = $request->headers["content-type"];
+ $request->headers["content-type"] = "{$contentTypeHeader}; boundary={$boundary}";
+
+ $value_params = [];
+ $file_params = [];
+
+ $disallow = ["\0", "\"", "\r", "\n"];
+
+ $body = [];
+
+ foreach ($request->body as $k => $v) {
+ $k = str_replace($disallow, "_", $k);
+ if (is_resource($v)) {
+ $file_params[] = $this->prepareFilePart($k, $v, $boundary);
+ } else if ($v instanceof FormPart) {
+ $value_params[] = $this->prepareFormPart($k, $v, $boundary);
+ } else {
+ $value_params[] = $this->prepareFormField($k, $v, $boundary);
+ }
+ }
+
+ $body = array_merge($value_params, $file_params);
+
+ // add boundary for each parameters
+ array_walk($body, function (&$part) use ($boundary) {
+ $part = "--{$boundary}" . self::LINEFEED . "{$part}";
+ });
+
+ // add final boundary
+ $body[] = "--{$boundary}--";
+ $body[] = "";
+
+ return implode(self::LINEFEED, $body);
+ }
+
+ public function decode($data)
+ {
+ throw new \Exception("Multipart does not support deserialization");
+ }
+
+ private function isAssociative(array $array)
+ {
+ return array_values($array) !== $array;
+ }
+
+ private function prepareFormField($partName, $value, $boundary)
+ {
+ return implode(self::LINEFEED, [
+ "Content-Disposition: form-data; name=\"{$partName}\"",
+ "",
+ filter_var($value),
+ ]);
+ }
+
+ private function prepareFilePart($partName, $file, $boundary)
+ {
+ $fileInfo = new finfo(FILEINFO_MIME_TYPE);
+ $filePath = stream_get_meta_data($file)['uri'];
+ $data = file_get_contents($filePath);
+ $mimeType = $fileInfo->buffer($data);
+
+ $splitFilePath = explode(DIRECTORY_SEPARATOR, $filePath);
+ $filePath = end($splitFilePath);
+ $disallow = ["\0", "\"", "\r", "\n"];
+ $filePath = str_replace($disallow, "_", $filePath);
+ return implode(self::LINEFEED, [
+ "Content-Disposition: form-data; name=\"{$partName}\"; filename=\"{$filePath}\"",
+ "Content-Type: {$mimeType}",
+ "",
+ $data,
+ ]);
+ }
+
+ private function prepareFormPart($partName, $formPart, $boundary)
+ {
+ $contentDisposition = "Content-Disposition: form-data; name=\"{$partName}\"";
+
+ $partHeaders = $formPart->getHeaders();
+ $formattedheaders = array_change_key_case($partHeaders);
+ if (array_key_exists("content-type", $formattedheaders)) {
+ if ($formattedheaders["content-type"] === "application/json") {
+ $contentDisposition .= "; filename=\"{$partName}.json\"";
+ }
+ $tempRequest = new HttpRequest('/', 'POST');
+ $tempRequest->headers = $formattedheaders;
+ $tempRequest->body = $formPart->getValue();
+ $encoder = new Encoder();
+ $partValue = $encoder->serializeRequest($tempRequest);
+ } else {
+ $partValue = $formPart->getValue();
+ }
+
+ $finalPartHeaders = [];
+ foreach ($partHeaders as $k => $v) {
+ $finalPartHeaders[] = "{$k}: {$v}";
+ }
+
+ $body = array_merge([$contentDisposition], $finalPartHeaders, [""], [$partValue]);
+
+ return implode(self::LINEFEED, $body);
+ }
+}
diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php index e2ce0ca..d6fa3cd 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php @@ -1,38 +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; - } -} +<?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;
+ }
+}
|