src/ChrisKonnertz/DeepLy/HttpClient/CurlHttpClient.php
public function ping($url)
    {
        if (! is_string($url)) {
            throw new \InvalidArgumentException('$url has to be a string');
        }

        $curl = curl_init($url);

        // Do not "include the header in the output" (from the docs).
        // Should make the response a little bit smaller.
        curl_setopt($curl, CURLOPT_HEADER, 0);
        // Set this to true, because if it is set to false, curl will echo the result!
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

        $startedAt = microtime(true);
        $result = curl_exec($curl);
        $duration = microtime(true) - $startedAt;

        curl_close($curl);

        if ($result === false) {
            throw new CallException('Did not get a valid response. API seems to be unreachable.');
        }

        return $duration;
    }
public function ping($url)
    {
        if (! is_string($url)) {
            throw new \InvalidArgumentException('$url has to be a string');
        }

        $curl = curl_init($url);

        // Do not "include the header in the output" (from the docs).
        // Should make the response a little bit smaller.
        curl_setopt($curl, CURLOPT_HEADER, 0);
        // Set this to true, because if it is set to false, curl will echo the result!
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

        $startedAt = microtime(true);
        $result = curl_exec($curl);
        $duration = microtime(true) - $startedAt;

        curl_close($curl);

        if ($result === false) {
            throw new CallException('Did not get a valid response. API seems to be unreachable.');
        }

        return $duration;
    }
Pings the API server. Returns the duration in seconds
or throws an exception if no valid response was received.

@param string $url The URL of the API endpoint
@return float
@throws CallException