fkooman\OAuth\Client\AccessToken::__construct PHP Method

__construct() public method

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

Usage Example

 public function __construct(array $data)
 {
     parent::__construct($data);
     if (array_key_exists('user_id_from_provider', $data)) {
         $this->user_id_from_provider = $data['user_id_from_provider'];
     } else {
         $this->user_id_from_provider = false;
     }
 }