![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/vendor/friendsofsymfony/oauth2-php/lib/ |
<?php namespace OAuth2; /** * OAuth2.0 draft v10 exception handling. * * @author Originally written by Naitik Shah <[email protected]>. * @author Update to draft v10 by Edison Wong <[email protected]>. * * @sa <a href="https://github.com/facebook/php-sdk">Facebook PHP SDK</a>. */ class OAuth2Exception extends \Exception { /** * The result from the API server that represents the exception information. * * @var array */ protected $result; /** * Make a new API Exception with the given result. * * @param array $result The result from the API server. */ public function __construct($result) { $this->result = $result; $code = isset($result['code']) ? $result['code'] : 0; if (isset($result['error'])) { // OAuth 2.0 Draft 10 style $message = $result['error']; } elseif (isset($result['message'])) { // cURL style $message = $result['message']; } else { $message = 'Unknown Error. Check getResult()'; } parent::__construct($message, $code); } /** * Return the associated result object returned by the API server. * * @return array The result from the API server. */ public function getResult() { return $this->result; } /** * Returns the associated type for the error. This will default to * 'Exception' when a type is not available. * * @return string The type for the error. */ public function getType() { if (isset($this->result['error'])) { $message = $this->result['error']; if (is_string($message)) { // OAuth 2.0 Draft 10 style return $message; } } return 'Exception'; } /** * 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; } }