| Total Complexity | 11 |
| Total Lines | 72 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | class ZohoOAuthTokens |
||
| 7 | { |
||
| 8 | |||
| 9 | private $refreshToken; |
||
| 10 | |||
| 11 | private $accessToken; |
||
| 12 | |||
| 13 | private $expiryTime; |
||
| 14 | |||
| 15 | private $userEmailId; |
||
| 16 | |||
| 17 | public function getRefreshToken() |
||
| 18 | { |
||
| 19 | return $this->refreshToken; |
||
| 20 | } |
||
| 21 | |||
| 22 | public function setRefreshToken($refreshToken) |
||
| 23 | { |
||
| 24 | $this->refreshToken = $refreshToken; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function getAccessToken() |
||
| 28 | { |
||
| 29 | if ($this->isValidAccessToken()) { |
||
| 30 | return $this->accessToken; |
||
| 31 | } |
||
| 32 | throw new ZohoOAuthException("Access token got expired!"); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function setAccessToken($accessToken) |
||
| 36 | { |
||
| 37 | $this->accessToken = $accessToken; |
||
| 38 | } |
||
| 39 | |||
| 40 | public function isValidAccessToken() |
||
| 41 | { |
||
| 42 | return ($this->getExpiryTime() - $this->getCurrentTimeInMillis()) > 1000; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function getExpiryTime() |
||
| 46 | { |
||
| 47 | return $this->expiryTime; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function setExpiryTime($expiryTime) |
||
| 51 | { |
||
| 52 | return $this->expiryTime = $expiryTime; |
||
| 53 | } |
||
| 54 | |||
| 55 | public function getCurrentTimeInMillis() |
||
| 56 | { |
||
| 57 | return round(microtime(true) * 1000); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * userEmailId |
||
| 62 | * |
||
| 63 | * @return String |
||
| 64 | */ |
||
| 65 | public function getUserEmailId() |
||
| 66 | { |
||
| 67 | return $this->userEmailId; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * userEmailId |
||
| 72 | * |
||
| 73 | * @param String $userEmailId |
||
| 74 | */ |
||
| 75 | public function setUserEmailId($userEmailId) |
||
| 76 | { |
||
| 77 | $this->userEmailId = $userEmailId; |
||
| 78 | } |
||
| 79 | } |