1 | <?php |
||
31 | class AccessToken |
||
32 | { |
||
33 | /** |
||
34 | * The access token value. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $value = ''; |
||
39 | |||
40 | /** |
||
41 | * Date when token expires. |
||
42 | * |
||
43 | * @var \DateTime|null |
||
44 | */ |
||
45 | protected $expiresAt; |
||
46 | |||
47 | /** |
||
48 | * Create a new access token entity. |
||
49 | * |
||
50 | * @param string $accessToken |
||
51 | * @param int $expiresAt |
||
52 | */ |
||
53 | public function __construct($accessToken, $expiresAt = 0) |
||
60 | |||
61 | /** |
||
62 | * Generate an app secret proof to sign a request to Graph. |
||
63 | * |
||
64 | * @param string $appSecret The app secret. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function getAppSecretProof($appSecret) |
||
72 | |||
73 | /** |
||
74 | * Getter for expiresAt. |
||
75 | * |
||
76 | * @return \DateTime|null |
||
77 | */ |
||
78 | public function getExpiresAt() |
||
82 | |||
83 | /** |
||
84 | * Determines whether or not this is an app access token. |
||
85 | * |
||
86 | * @return bool |
||
87 | */ |
||
88 | public function isAppAccessToken() |
||
92 | |||
93 | /** |
||
94 | * Determines whether or not this is a long-lived token. |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | public function isLongLived() |
||
110 | |||
111 | /** |
||
112 | * Checks the expiration of the access token. |
||
113 | * |
||
114 | * @return boolean|null |
||
115 | */ |
||
116 | public function isExpired() |
||
128 | |||
129 | /** |
||
130 | * Returns the access token as a string. |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function getValue() |
||
138 | |||
139 | /** |
||
140 | * Returns the access token as a string. |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | public function __toString() |
||
148 | |||
149 | /** |
||
150 | * Setter for expires_at. |
||
151 | * |
||
152 | * @param int $timeStamp |
||
153 | */ |
||
154 | protected function setExpiresAtFromTimeStamp($timeStamp) |
||
160 | } |
||
161 |