Last active
March 8, 2016 21:02
-
-
Save alexbilbie/833024da674ecc7e5e61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace OAuth; | |
class AccessToken | |
{ | |
/** | |
* @var string | |
*/ | |
protected $type = 'Bearer'; | |
/** | |
* @var string | |
*/ | |
private $value; | |
/** | |
* @var \DateTime | |
*/ | |
private $expiresAt; | |
/** | |
* @var int|string | |
*/ | |
private $ownerId; | |
/** | |
* @var string | |
*/ | |
private $ownerType; | |
/** | |
* @param string $value The access token value | |
* @param \DateTime $expiresAt The expiry time of the access token | |
* @param string|int $ownerId The identifier of the owner of the token | |
* @param string $ownerType The type of the owner (default: "user") | |
*/ | |
public function __construct($value, \DateTime $expiresAt, $ownerId, $ownerType = 'user') | |
{ | |
$this->value = $value; | |
$this->expiresAt = $expiresAt; | |
$this->ownerId = $ownerId; | |
$this->ownerType = $ownerType; | |
} | |
/** | |
* @return string | |
*/ | |
public function __toString() | |
{ | |
return $this->value; | |
} | |
/** | |
* @return \DateTime | |
*/ | |
public function getExpiresAt() | |
{ | |
return $this->expiresAt; | |
} | |
/** | |
* @return int|string | |
*/ | |
public function getOwnerId() | |
{ | |
return $this->ownerId; | |
} | |
/** | |
* @return string | |
*/ | |
public function getOwnerType() | |
{ | |
return $this->ownerType; | |
} | |
/** | |
* @return string | |
*/ | |
public function getTokenType() | |
{ | |
return $this->type; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace OAuth; | |
class MacToken extends AccessToken | |
{ | |
/** | |
* @var string | |
*/ | |
protected $type = 'MAC'; | |
/** | |
* @var string | |
*/ | |
private $macKey; | |
/** | |
* @var string | |
*/ | |
private $macAlgorithm; | |
/** | |
* @param string $value The access token value | |
* @param string $macKey The MAC key value | |
* @param string $macAlgorithm The MAC algorithm | |
* @param \DateTime $expiresAt The expiry time of the access token | |
* @param string|int $ownerId The identifier of the owner of the token | |
* @param string $ownerType The type of the owner (default: "user") | |
*/ | |
public function __construct($value, $macKey, $macAlgorithm, \DateTime $expiresAt, $ownerId, $ownerType = 'user') | |
{ | |
parent::__construct($value, $expiresAt, $ownerId, $ownerType); | |
$this->macKey = $macKey; | |
$this->macAlgorithm = $macAlgorithm; | |
} | |
/** | |
* @return string | |
*/ | |
public function getMacKey() | |
{ | |
return $this->macKey; | |
} | |
/** | |
* @return string | |
*/ | |
public function getMacAlgorithm() | |
{ | |
return $this->macAlgorithm; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please comment here going forward - https://groups.google.com/forum/#!topic/thephpleague/yZkYhIr3pS4