protected static function createNew(
        int $ttl,
        TokenOwnerInterface $owner = null,
        Client $client = null,
        array $scopes = null
    ): self {
        if (is_array($scopes)) {
            $scopes = array_map(function ($scope) {
                return (string) $scope;
            }, $scopes);
        }

        $token = new static();

        $token->token = bin2hex(random_bytes(20));
        $token->owner = $owner;
        $token->client = $client;
        $token->scopes = $scopes ?? [];
        $token->expiresAt = $ttl ? (new DateTime('@' . time(), new DateTimeZone('UTC')))->modify("+$ttl seconds") : null;

        return $token;
    }