From 0a5455642f58a58062b3a5be0fc85a9f6acbacc9 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 4 Sep 2012 12:31:04 +0100 Subject: [PATCH] PSR style if/else block --- src/Oauth2/Client/Exception.php | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Oauth2/Client/Exception.php b/src/Oauth2/Client/Exception.php index 9d3b995d..0fea8691 100755 --- a/src/Oauth2/Client/Exception.php +++ b/src/Oauth2/Client/Exception.php @@ -27,19 +27,20 @@ class Exception extends \Exception { $code = isset($result['code']) ? $result['code'] : 0; - if (isset($result['error'])) - { + if (isset($result['error'])) { + // OAuth 2.0 Draft 10 style $message = $result['error']; - } - elseif (isset($result['message'])) - { + + } elseif (isset($result['message'])) { + // cURL style $message = $result['message']; - } - else - { + + } else { + $message = 'Unknown Error.'; + } parent::__construct($message, $code); @@ -54,15 +55,16 @@ class Exception extends \Exception { */ public function getType() { - if (isset($this->result['error'])) - { + if (isset($this->result['error'])) { + $message = $this->result['error']; - if (is_string($message)) - { + + if (is_string($message)) { // OAuth 2.0 Draft 10 style return $message; } } + return 'Exception'; } @@ -75,10 +77,11 @@ class Exception extends \Exception { public function __toString() { $str = $this->getType() . ': '; - if ($this->code != 0) - { + + if ($this->code != 0) { $str .= $this->code . ': '; } + return $str . $this->message; }