Use Interfaces anywhere.
In practice, there were still too many concrete classes, which makes integration into a framework hard. To overcome this, the codebase has been refactored to use Interfaces when a resource is needed. All necessary Interfaces have been created, and the existing concrete classes now implement these interfaces.
This commit is contained in:
64
src/JacobKiers/OAuth/Consumer/Consumer.php
Normal file
64
src/JacobKiers/OAuth/Consumer/Consumer.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* OAuth
|
||||
*
|
||||
* @package OAuth
|
||||
* @author Andy Smith
|
||||
* @author Gary Jones <gary@garyjones.co.uk>
|
||||
* @license https://raw.github.com/jacobkiers/OAuth/master/LICENSE MIT
|
||||
* @link https://github.com/jacobkiers/OAuth
|
||||
*/
|
||||
|
||||
namespace JacobKiers\OAuth\Consumer;
|
||||
|
||||
use \JacobKiers\OAuth\Credential;
|
||||
|
||||
/**
|
||||
* Consumer holds the properties of a single Consumer / consumer.
|
||||
*
|
||||
* @package OAuth
|
||||
* @author Gary Jones <gary@garyjones.co.uk>
|
||||
*/
|
||||
class Consumer extends Credential implements ConsumerInterface
|
||||
{
|
||||
/**
|
||||
* URL to which authorized requests will redirect to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $callback_url;
|
||||
|
||||
/**
|
||||
* Constructs a new Consumer object and populates the required parameters.
|
||||
*
|
||||
* @param string $key Consumer key / identifier.
|
||||
* @param string $secret Consumer shared-secret.
|
||||
* @param string $callback_url URL to which authorized request will redirect to.
|
||||
*/
|
||||
public function __construct($key, $secret, $callback_url = null)
|
||||
{
|
||||
$this->setKey($key);
|
||||
$this->setSecret($secret);
|
||||
$this->setCallbackUrl($callback_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the callback URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCallbackUrl()
|
||||
{
|
||||
return $this->callback_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the callbackURL
|
||||
*
|
||||
* @param string $callback_url
|
||||
*/
|
||||
public function setCallbackUrl($callback_url)
|
||||
{
|
||||
$this->callback_url = $callback_url;
|
||||
}
|
||||
}
|
||||
48
src/JacobKiers/OAuth/Consumer/ConsumerInterface.php
Normal file
48
src/JacobKiers/OAuth/Consumer/ConsumerInterface.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* OAuth
|
||||
*
|
||||
* @package OAuth
|
||||
* @author Jacob Kiers <jacob@alphacomm.nl>
|
||||
* @license https://raw.github.com/jacobkiers/OAuth/master/LICENSE MIT
|
||||
* @link https://github.com/jacobkiers/OAuth
|
||||
*/
|
||||
|
||||
namespace JacobKiers\OAuth\Consumer;
|
||||
|
||||
/**
|
||||
* Consumer holds the properties of a single Consumer / consumer.
|
||||
*
|
||||
* @package OAuth
|
||||
* @author Jacob Kiers <jacob@alphacomm.nl>
|
||||
*/
|
||||
interface ConsumerInterface
|
||||
{
|
||||
/**
|
||||
* Get the callback URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCallbackUrl();
|
||||
|
||||
/**
|
||||
* Set the callbackURL
|
||||
*
|
||||
* @param string $callback_url
|
||||
*/
|
||||
public function setCallbackUrl($callback_url);
|
||||
|
||||
/**
|
||||
* Return the Consumer key.
|
||||
*
|
||||
* @return string Consumer key.
|
||||
*/
|
||||
public function getKey();
|
||||
|
||||
/**
|
||||
* Return the Consumer secret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSecret();
|
||||
}
|
||||
Reference in New Issue
Block a user