# give/4.17.0/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/AccessToken.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.17.0. 70 lines.

- Page: https://pluginprobe.com/plugins/give/4.17.0/code/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/AccessToken.php
- Raw: https://pluginprobe.com/plugins/give/4.17.0/raw/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/AccessToken.php
- Modified: 2023-06-29T16:27:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.17.0/code/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/AccessToken.php#L10-L20`.

```php
<?php

namespace Give\PaymentGateways\PayPalCommerce\PayPalCheckoutSdk;

/**
 * Class AccessToken.
 *
 * @since 2.25.0
 */
class AccessToken extends \PayPalCheckoutSdk\Core\AccessToken
{
    /**
     * Token creation date.
     *
     * @since 2.25.0
     * @var int
     */
    protected $nonce;

    /**
     * Returns true if the token is expired.
     *
     * @since 2.25.0
     */
    public function isExpired(): bool
    {
        return time() >= $this->getExpirationDate();
    }

    /**
     * Returns the token creation date.
     *
     * The creation date is the first 19 characters of the nonce.
     * Example nonce: 2023-02-07T05:03:17ZPeYxT6_thWGlTaamtMGYt5RQzVHx5B4dlNjLNhoF0tM
     *
     * @since 2.25.0
     */
    protected function getCreationDate(): int
    {
        return strtotime(substr($this->nonce, 0, 19));
    }

    /**
     * Returns the token expiration date.
     *
     * @since 2.25.0
     */
    protected function getExpirationDate(): int
    {
        return $this->getCreationDate() + $this->expiresIn;
    }

    /**
     * Returns the class object.
     *
     * @since 2.25.0
     */
    public static function fromArray(array $data): self
    {
        $accessToken = new self(
            $data['accessToken'],
            $data['tokenType'],
            $data['expiresIn']
        );
        $accessToken->nonce = $data['nonce'];

        return $accessToken;
    }
}

```
