public function __construct(array $data)
{
foreach (array('access_token', 'token_type') as $key) {
if (!array_key_exists($key, $data)) {
throw new TokenResponseException(sprintf("missing field '%s'", $key));
}
}
$this->setAccessToken($data['access_token']);
$this->setTokenType($data['token_type']);
$this->expiresIn = null;
$this->refreshToken = null;
$this->scope = null;
if (array_key_exists('expires_in', $data)) {
$this->setExpiresIn($data['expires_in']);
}
if (array_key_exists('refresh_token', $data)) {
$this->setRefreshToken($data['refresh_token']);
}
if (array_key_exists('scope', $data)) {
$this->setScope($data['scope']);
}
}