Fixes and cleanup

Signed-off-by: Alex Bilbie <alex@alexbilbie.com>
This commit is contained in:
Alex Bilbie 2012-10-05 15:03:15 +01:00
parent ec191cffe1
commit bef7a212e3
2 changed files with 7 additions and 31 deletions

View File

@ -1,43 +1,19 @@
<?php <?php
namespace Oauth2\Client; namespace OAuth2\Client;
include('Exception.php'); include_once('Exception.php');
include('Token.php');
include('IDP.php');
/** class Client
* OAuth2.0
*
* @author Phil Sturgeon < @philsturgeon >
*/
class Provider
{ {
public function __construct($name, array $options = null)
/**
* Create a new provider client.
*
* @param string provider name
* @param array provider options
* @return OAuth_Provider
*/
public function __construct($name, array $options = NULL)
{ {
$name = ucfirst(strtolower($name)); if ( ! class_exists($name)) {
$fileName = 'Provider/'.$name.'.php'; throw new OAuth2\Client\Exception('There is no identity provider called: '.$name);
if (file_exists($fileName)) {
require_once $fileName;
} else {
throw new Exception('There is no provider configuration file for '.$name);
} }
return new $name($options); return new $name($options);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Oauth2\Client; namespace OAuth2\Client;
class Exception extends \Exception class Exception extends \Exception
{ {