diff --git a/src/OAuth2/AuthServer.php b/src/OAuth2/AuthServer.php index 69a78831..82f464fa 100644 --- a/src/OAuth2/AuthServer.php +++ b/src/OAuth2/AuthServer.php @@ -67,7 +67,7 @@ class AuthServer * Exception error codes * @var array */ - protected $exceptionCodes = array( + protected static $exceptionCodes = array( 0 => 'invalid_request', 1 => 'unauthorized_client', 2 => 'access_denied', @@ -110,6 +110,17 @@ class AuthServer return self::$exceptionMessages[$error]; } + /** + * Get an exception code + * + * @param integer $code The exception code + * @return string The exception code type + */ + public static function getExceptionType($code = 0) + { + return self::$exceptionCodes[$code]; + } + /** * Create a new OAuth2 authentication server * diff --git a/tests/authentication/AuthServerTest.php b/tests/authentication/AuthServerTest.php index a6b2b1b3..f8f3e35e 100644 --- a/tests/authentication/AuthServerTest.php +++ b/tests/authentication/AuthServerTest.php @@ -45,6 +45,11 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase $this->assertEquals($v['access_denied'], $m); } + public function test_getExceptionCode() + { + $this->assertEquals('access_denied', OAuth2\AuthServer::getExceptionType(2)); + } + public function test_hasGrantType() { $this->assertFalse(OAuth2\AuthServer::hasGrantType('test'));