private function getClusterHeader($url)
    {
        $cacheKey = 'project-cluster:' . $url;
        $cluster = $this->cache ? $this->cache->fetch($cacheKey) : false;
        if ($cluster === false) {
            $this->debug('Making a HEAD request to identify project from URL: ' . $url);
            try {
                $response = $this->api->getHttpClient()->head($url, [
                    'auth' => false,
                    'timeout' => 5,
                    'connect_timeout' => 5,
                    'allow_redirects' => false,
                ]);
            } catch (RequestException $e) {
                // We can use a failed response, if one exists.
                if ($e->getResponse()) {
                    $response = $e->getResponse();
                } else {
                    $this->debug($e->getMessage());

                    return false;
                }
            }
            $cluster = $response->getHeaderAsArray($this->config->get('service.header_prefix') . '-cluster');
            $canCache = !empty($cluster)
                || ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300);
            if ($canCache) {
                $this->cache->save($cacheKey, $cluster, 86400);
            }
        }

        return is_array($cluster) ? reset($cluster) : false;
    }
private function getClusterHeader($url)
    {
        $cacheKey = 'project-cluster:' . $url;
        $cluster = $this->cache ? $this->cache->fetch($cacheKey) : false;
        if ($cluster === false) {
            $this->debug('Making a HEAD request to identify project from URL: ' . $url);
            try {
                $response = $this->api->getHttpClient()->head($url, [
                    'auth' => false,
                    'timeout' => 5,
                    'connect_timeout' => 5,
                    'allow_redirects' => false,
                ]);
            } catch (RequestException $e) {
                // We can use a failed response, if one exists.
                if ($e->getResponse()) {
                    $response = $e->getResponse();
                } else {
                    $this->debug($e->getMessage());

                    return false;
                }
            }
            $cluster = $response->getHeaderAsArray($this->config->get('service.header_prefix') . '-cluster');
            $canCache = !empty($cluster)
                || ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300);
            if ($canCache) {
                $this->cache->save($cacheKey, $cluster, 86400);
            }
        }

        return is_array($cluster) ? reset($cluster) : false;
    }
private function getClusterHeader ( $ url ) { $ cacheKey = 'project-cluster:' . $ url ; $ cluster = $ this -> cache ? $ this -> cache -> fetch ( $ cacheKey ) : false ; if ( $ cluster === false ) { $ this -> debug ( 'Making a HEAD request to identify project from URL: ' . $ url ) ; try { $ response = $ this -> api -> getHttpClient ( ) -> head ( $ url , [ 'auth' => false , 'timeout' => 5 , 'connect_timeout' => 5 , 'allow_redirects' => false , ] ) ; } catch ( RequestException $ e ) { // We can use a failed response, if one exists. if ( $ e -> getResponse ( ) ) { $ response = $ e -> getResponse ( ) ; } else { $ this -> debug ( $ e -> getMessage ( ) ) ; return false ; } } $ cluster = $ response -> getHeaderAsArray ( $ this -> config -> get ( 'service.header_prefix' ) . '-cluster' ) ; $ canCache = ! empty ( $ cluster ) || ( $ response -> getStatusCode ( ) >= 200 && $ response -> getStatusCode ( ) < 300 ) ; if ( $ canCache ) { $ this -> cache -> save ( $ cacheKey , $ cluster , 86400 ) ; } } return is_array ( $ cluster ) ? reset ( $ cluster ) : false ; }
Get a project cluster from its URL.

@param string $url

@return string|false
Get a project cluster from its URL .