OAuthCommonTokenAbstractToken

Base token implementation for any OAuth version.

Defined (1)

The class is defined in the following location(s).

/lib/PHPoAuthLib/src/OAuth/Common/Token/AbstractToken.php  
  1. abstract class AbstractToken implements TokenInterface 
  2. /** 
  3. * @var string 
  4. */ 
  5. protected $accessToken; 
  6.  
  7. /** 
  8. * @var string 
  9. */ 
  10. protected $refreshToken; 
  11.  
  12. /** 
  13. * @var int 
  14. */ 
  15. protected $endOfLife; 
  16.  
  17. /** 
  18. * @var array 
  19. */ 
  20. protected $extraParams = array(); 
  21.  
  22. /** 
  23. * @param string $accessToken 
  24. * @param string $refreshToken 
  25. * @param int $lifetime 
  26. * @param array $extraParams 
  27. */ 
  28. public function __construct($accessToken = null, $refreshToken = null, $lifetime = null, $extraParams = array()) 
  29. $this->accessToken = $accessToken; 
  30. $this->refreshToken = $refreshToken; 
  31. $this->setLifetime($lifetime); 
  32. $this->extraParams = $extraParams; 
  33.  
  34. /** 
  35. * @return string 
  36. */ 
  37. public function getAccessToken() 
  38. return $this->accessToken; 
  39.  
  40. /** 
  41. * @return string 
  42. */ 
  43. public function getRefreshToken() 
  44. return $this->refreshToken; 
  45.  
  46. /** 
  47. * @return int 
  48. */ 
  49. public function getEndOfLife() 
  50. return $this->endOfLife; 
  51.  
  52. /** 
  53. * @param array $extraParams 
  54. */ 
  55. public function setExtraParams(array $extraParams) 
  56. $this->extraParams = $extraParams; 
  57.  
  58. /** 
  59. * @return array 
  60. */ 
  61. public function getExtraParams() 
  62. return $this->extraParams; 
  63.  
  64. /** 
  65. * @param string $accessToken 
  66. */ 
  67. public function setAccessToken($accessToken) 
  68. $this->accessToken = $accessToken; 
  69.  
  70. /** 
  71. * @param int $endOfLife 
  72. */ 
  73. public function setEndOfLife($endOfLife) 
  74. $this->endOfLife = $endOfLife; 
  75.  
  76. /** 
  77. * @param int $lifetime 
  78. */ 
  79. public function setLifetime($lifetime) 
  80. if (0 === $lifetime || static::EOL_NEVER_EXPIRES === $lifetime) { 
  81. $this->endOfLife = static::EOL_NEVER_EXPIRES; 
  82. } elseif (null !== $lifetime) { 
  83. $this->endOfLife = intval($lifetime) + time(); 
  84. } else { 
  85. $this->endOfLife = static::EOL_UNKNOWN; 
  86.  
  87. /** 
  88. * @param string $refreshToken 
  89. */ 
  90. public function setRefreshToken($refreshToken) 
  91. $this->refreshToken = $refreshToken;