Automattic\WooCommerce\Internal\AddressProvider
AbstractAutomatticAddressProvider::get_jwt_cache_duration
Gets the cache duration for the JWT.
Method of the class: AbstractAutomatticAddressProvider{}
No Hooks.
Returns
Int. The cache duration for the JWT.
Usage
$AbstractAutomatticAddressProvider = new AbstractAutomatticAddressProvider(); $AbstractAutomatticAddressProvider->get_jwt_cache_duration( $jwt );
- $jwt(string) (required)
- The JWT for the address service.
AbstractAutomatticAddressProvider::get_jwt_cache_duration() AbstractAutomatticAddressProvider::get jwt cache duration code WC 10.3.3
public function get_jwt_cache_duration( $jwt ) {
$parts = JsonWebToken::get_parts( $jwt );
if ( property_exists( $parts->payload, 'exp' ) ) {
return max( $parts->payload->exp - time(), 0 );
}
}