public function checkUpdate() : ?int
    {
        $success = null;

        try {
            $cachedVersion = $this->cache->getItem('browscap.version', false, $success);
        } catch (InvalidArgumentException $e) {
            throw new ErrorCachedVersionException('an error occured while reading the data version from the cache', 0, $e);
        }

        if (! $cachedVersion) {
            // could not load version from cache
            throw new NoCachedVersionException('there is no cached version available, please update from remote');
        }

        $uri = (new IniLoader())->getRemoteVersionUrl();

        try {
            /** @var \Psr\Http\Message\ResponseInterface $response */
            $response = $this->client->request('get', $uri, ['connect_timeout' => $this->connectTimeout]);
        } catch (\GuzzleHttp\Exception\GuzzleException $e) {
            throw new FetcherException(
                sprintf(
                    'an error occured while fetching version data from URI %s',
                    $uri
                ),
                0,
                $e
            );
        }

        if (200 !== $response->getStatusCode()) {
            throw new FetcherException(
                sprintf(
                    'an error occured while fetching version data from URI %s: StatusCode was %d',
                    $uri,
                    $response->getStatusCode()
                )
            );
        }

        try {
            $remoteVersion = $response->getBody()->getContents();
        } catch (\Throwable $e) {
            throw new FetcherException(
                sprintf(
                    'an error occured while fetching version data from URI %s: StatusCode was %d',
                    $uri,
                    $response->getStatusCode()
                ),
                0,
                $e
            );
        }

        if (! $remoteVersion) {
            // could not load remote version
            throw new FetcherException(
                'could not load version from remote location'
            );
        }

        if ($cachedVersion && $remoteVersion && $remoteVersion <= $cachedVersion) {
            throw new NoNewVersionException('there is no newer version available');
        }

        $this->logger->info(
            'a newer version is available, local version: ' . $cachedVersion . ', remote version: ' . $remoteVersion
        );

        return (int) $cachedVersion;
    }