From d94446782a475a0a5c0b655a91ccf5db9576a341 Mon Sep 17 00:00:00 2001 From: GaryJones Date: Thu, 22 Nov 2012 18:11:12 +0000 Subject: [PATCH] Rename OAuth\Exception back to OAuthException, to follow the standard PHP way of naming predefined / SPL exceptions. --- .../{Exception.php => OAuthException.php} | 2 +- src/GaryJones/OAuth/Request.php | 4 +-- src/GaryJones/OAuth/Server.php | 36 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) rename src/GaryJones/OAuth/{Exception.php => OAuthException.php} (89%) diff --git a/src/GaryJones/OAuth/Exception.php b/src/GaryJones/OAuth/OAuthException.php similarity index 89% rename from src/GaryJones/OAuth/Exception.php rename to src/GaryJones/OAuth/OAuthException.php index b94544d..b6c7383 100644 --- a/src/GaryJones/OAuth/Exception.php +++ b/src/GaryJones/OAuth/OAuthException.php @@ -17,6 +17,6 @@ namespace GaryJones\OAuth; * @package OAuth * @author Andy Smith */ -class Exception extends \Exception +class OAuthException extends \Exception { } diff --git a/src/GaryJones/OAuth/Request.php b/src/GaryJones/OAuth/Request.php index d98d15a..47dd548 100644 --- a/src/GaryJones/OAuth/Request.php +++ b/src/GaryJones/OAuth/Request.php @@ -329,7 +329,7 @@ class Request * * @return string * - * @throws GaryJones\OAuth\Exception + * @throws GaryJones\OAuth\OAuthException */ public function toHeader($realm = null) { @@ -347,7 +347,7 @@ class Request continue; } if (is_array($v)) { - throw new Exception('Arrays not supported in headers'); + throw new OAuthException('Arrays not supported in headers'); } $out .= ($first) ? ' ' : ','; $out .= Util::urlencodeRfc3986($k) . diff --git a/src/GaryJones/OAuth/Server.php b/src/GaryJones/OAuth/Server.php index f727057..4840963 100644 --- a/src/GaryJones/OAuth/Server.php +++ b/src/GaryJones/OAuth/Server.php @@ -149,7 +149,7 @@ class Server * * @return string * - * @throws GaryJones\OAuth\Exception + * @throws GaryJones\OAuth\OAuthException */ private function getVersion(Request &$request) { @@ -160,7 +160,7 @@ class Server $version = '1.0'; } if ($version !== $this->version) { - throw new Exception("OAuth version '$version' not supported"); + throw new OAuthException("OAuth version '$version' not supported"); } return $version; } @@ -172,7 +172,7 @@ class Server * * @return string Signature method name. * - * @throws GaryJones\OAuth\Exception + * @throws GaryJones\OAuth\OAuthException */ private function getSignatureMethod(Request $request) { @@ -181,11 +181,11 @@ class Server if (!$signature_method) { // According to chapter 7 ("Accessing Protected Resources") the signature-method // parameter is required, and we can't just fallback to PLAINTEXT - throw new Exception('No signature method parameter. This parameter is required'); + throw new OAuthException('No signature method parameter. This parameter is required'); } if (!in_array($signature_method, array_keys($this->signature_methods))) { - throw new Exception( + throw new OAuthException( "Signature method '$signature_method' not supported, try one of the following: " . implode(", ", array_keys($this->signature_methods)) ); @@ -200,19 +200,19 @@ class Server * * @return GaryJones\OAuth\Client * - * @throws GaryJones\OAuth\Exception + * @throws GaryJones\OAuth\OAuthException */ private function getClient(Request $request) { $client_key = $request instanceof Request ? $request->getParameter('oauth_consumer_key') : null; if (!$client_key) { - throw new Exception('Invalid client key'); + throw new OAuthException('Invalid client key'); } $client = $this->data_store->lookupClient($client_key); if (!$client) { - throw new Exception('Invalid client'); + throw new OAuthException('Invalid client'); } return $client; @@ -227,7 +227,7 @@ class Server * * @return GaryJones\OAuth\Token * - * @throws GaryJones\OAuth\Exception + * @throws GaryJones\OAuth\OAuthException */ private function getToken(Request $request, Client $client, $token_type = 'access') { @@ -235,7 +235,7 @@ class Server $token = $this->data_store->lookupToken($client, $token_type, $token_field); if (!$token) { - throw new Exception("Invalid $token_type token: $token_field"); + throw new OAuthException("Invalid $token_type token: $token_field"); } return $token; } @@ -249,7 +249,7 @@ class Server * @param GaryJones\OAuth\Client $client * @param GaryJones\OAuth\Token $token * - * @throws GaryJones\OAuth\Exception + * @throws GaryJones\OAuth\OAuthException */ private function checkSignature(Request $request, Client $client, Token $token) { @@ -266,7 +266,7 @@ class Server $valid_sig = $signature_method->checkSignature($request, $client, $token, $signature); if (!$valid_sig) { - throw new Exception('Invalid signature'); + throw new OAuthException('Invalid signature'); } } @@ -275,18 +275,18 @@ class Server * * @param int $timestamp * - * @throws GaryJones\OAuth\Exception + * @throws GaryJones\OAuth\OAuthException */ private function checkTimestamp($timestamp) { if (!$timestamp) { - throw new Exception('Missing timestamp parameter. The parameter is required'); + throw new OAuthException('Missing timestamp parameter. The parameter is required'); } // verify that timestamp is recentish $now = time(); if (abs($now - $timestamp) > $this->timestamp_threshold) { - throw new Exception("Expired timestamp, yours $timestamp, ours $now"); + throw new OAuthException("Expired timestamp, yours $timestamp, ours $now"); } } @@ -298,18 +298,18 @@ class Server * @param string $nonce * @param int $timestamp * - * @throws GaryJones\OAuth\Exception + * @throws GaryJones\OAuth\OAuthException */ private function checkNonce(Client $client, Token $token, $nonce, $timestamp) { if (!$nonce) { - throw new Exception('Missing nonce parameter. The parameter is required'); + throw new OAuthException('Missing nonce parameter. The parameter is required'); } // verify that the nonce is uniqueish $found = $this->data_store->lookupNonce($client, $token, $nonce, $timestamp); if ($found) { - throw new Exception('Nonce already used: ' . $nonce); + throw new OAuthException('Nonce already used: ' . $nonce); } } }