From 6854cb3f4d8219cf1829e32122eb2502a916eae9 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 1 Feb 2020 09:05:48 +0100 Subject: initial checkin --- .../oauth2-client/src/Exception/IDPException.php | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 vendor/league/oauth2-client/src/Exception/IDPException.php (limited to 'vendor/league/oauth2-client/src/Exception/IDPException.php') diff --git a/vendor/league/oauth2-client/src/Exception/IDPException.php b/vendor/league/oauth2-client/src/Exception/IDPException.php new file mode 100644 index 0000000..668a7e7 --- /dev/null +++ b/vendor/league/oauth2-client/src/Exception/IDPException.php @@ -0,0 +1,69 @@ +result = $result; + + $code = isset($result['code']) ? $result['code'] : 0; + + if (isset($result['error']) && $result['error'] !== '') { + // OAuth 2.0 Draft 10 style + $message = $result['error']; + } elseif (isset($result['message']) && $result['message'] !== '') { + // cURL style + $message = $result['message']; + } else { + $message = 'Unknown Error.'; + } + + parent::__construct($message, $code); + } + + public function getResponseBody() + { + return $this->result; + } + + public function getType() + { + $result = 'Exception'; + + if (isset($this->result['error'])) { + $message = $this->result['error']; + + if (is_string($message)) { + // OAuth 2.0 Draft 10 style + $result = $message; + } + } + + return $result; + } + + /** + * To make debugging easier. + * + * @return string The string representation of the error. + */ + public function __toString() + { + $str = $this->getType().': '; + + if ($this->code != 0) { + $str .= $this->code.': '; + } + + return $str.$this->message; + } +} -- cgit v1.2.3-70-g09d2