1 | <?php |
||
13 | class Access |
||
14 | { |
||
15 | /** |
||
16 | * @var string $token The access token itself |
||
17 | */ |
||
18 | protected $token; |
||
19 | |||
20 | /** |
||
21 | * @var string $tokenType The type of the token |
||
22 | */ |
||
23 | protected $tokenType; |
||
24 | |||
25 | /** |
||
26 | * @var int $expiresIn The time for the token to expire in seconds |
||
27 | */ |
||
28 | protected $expiresIn; |
||
29 | |||
30 | /** |
||
31 | * @var \DateTime $createdAt when was the token created |
||
32 | */ |
||
33 | protected $createdAt; |
||
34 | |||
35 | /** |
||
36 | * @var \DateTime $expiresAt when is the token expiring |
||
37 | */ |
||
38 | protected $expiresAt; |
||
39 | |||
40 | /** |
||
41 | * Constructor |
||
42 | * |
||
43 | * @param string $accessToken Access token |
||
44 | * @param string $tokenType Token type |
||
45 | * @param int $expiresIn Expires in (seconds) |
||
46 | */ |
||
47 | public function __construct($accessToken, $tokenType, $expiresIn) |
||
56 | |||
57 | /** |
||
58 | * Create token from json object |
||
59 | * |
||
60 | * @param \stdClass $jsonObject JSON object |
||
61 | * |
||
62 | * @return Access |
||
63 | */ |
||
64 | public static function fromJson($jsonObject) |
||
68 | |||
69 | /** |
||
70 | * Check if the token is expired |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function isExpired() |
||
78 | |||
79 | /** |
||
80 | * Get the token string |
||
81 | * |
||
82 | * @return string |
||
83 | * |
||
84 | * @throws Expired |
||
85 | */ |
||
86 | public function getToken() |
||
94 | } |
||
95 |