protected function fetchApi1($result, $valuesKey = 'values')
    {
        /** @var Request $request */
        $request = $this->client->getLastRequest();

        if (!array_key_exists($valuesKey, $result)) {
            throw new \RuntimeException(
                sprintf(
                    'No values-key "%s" found in resource "%s", please report this bug to the Gush developers.',
                    $valuesKey,
                    $request->getResource()
                )
            );
        }

        $fullResult = $result[$valuesKey];
        if ($this->perPage !== null && $this->perPage <= 50) {
            return $fullResult;
        }

        // The api is limited to 50 per page
        // So everything higher then 50 requires additional call(s)

        $urlComponents = parse_url($request->getResource());
        parse_str($urlComponents['query'], $query);
        $urlComponents['query'] = $query;

        $url = $request->getHost().$urlComponents['path'].'?';
        $limit = $urlComponents['query']['limit'];
        $count = isset($result['count']) ? $result['count'] : $urlComponents['limit'];
        $pages = ceil($count / $limit);

        for ($page = $this->page + 1; $page <= $pages; ++$page) {
            $urlComponents['query']['start'] = abs($page - 1) * $limit;

            $response = $this->client->get($url.http_build_query($urlComponents['query'], '', '&'));
            $result = json_decode($response->getContent(), true);

            $fullResult = array_merge($fullResult, $result[$valuesKey]);

            // We only wanted one, so stop now
            if ($this->perPage !== null) {
                break;
            }
        }

        return $fullResult;
    }
protected function fetchApi1($result, $valuesKey = 'values')
    {
        /** @var Request $request */
        $request = $this->client->getLastRequest();

        if (!array_key_exists($valuesKey, $result)) {
            throw new \RuntimeException(
                sprintf(
                    'No values-key "%s" found in resource "%s", please report this bug to the Gush developers.',
                    $valuesKey,
                    $request->getResource()
                )
            );
        }

        $fullResult = $result[$valuesKey];
        if ($this->perPage !== null && $this->perPage <= 50) {
            return $fullResult;
        }

        // The api is limited to 50 per page
        // So everything higher then 50 requires additional call(s)

        $urlComponents = parse_url($request->getResource());
        parse_str($urlComponents['query'], $query);
        $urlComponents['query'] = $query;

        $url = $request->getHost().$urlComponents['path'].'?';
        $limit = $urlComponents['query']['limit'];
        $count = isset($result['count']) ? $result['count'] : $urlComponents['limit'];
        $pages = ceil($count / $limit);

        for ($page = $this->page + 1; $page <= $pages; ++$page) {
            $urlComponents['query']['start'] = abs($page - 1) * $limit;

            $response = $this->client->get($url.http_build_query($urlComponents['query'], '', '&'));
            $result = json_decode($response->getContent(), true);

            $fullResult = array_merge($fullResult, $result[$valuesKey]);

            // We only wanted one, so stop now
            if ($this->perPage !== null) {
                break;
            }
        }

        return $fullResult;
    }
protected function fetchApi1 ( $ result , $ valuesKey = 'values' ) { /** @var Request $request */ $ request = $ this -> client -> getLastRequest ( ) ; if ( ! array_key_exists ( $ valuesKey , $ result ) ) { throw new \ RuntimeException ( sprintf ( 'No values-key "%s" found in resource "%s", please report this bug to the Gush developers.' , $ valuesKey , $ request -> getResource ( ) ) ) ; } $ fullResult = $ result [ $ valuesKey ] ; if ( $ this -> perPage !== null && $ this -> perPage <= 50 ) { return $ fullResult ; } // The api is limited to 50 per page // So everything higher then 50 requires additional call(s) $ urlComponents = parse_url ( $ request -> getResource ( ) ) ; parse_str ( $ urlComponents [ 'query' ] , $ query ) ; $ urlComponents [ 'query' ] = $ query ; $ url = $ request -> getHost ( ) . $ urlComponents [ 'path' ] . '?' ; $ limit = $ urlComponents [ 'query' ] [ 'limit' ] ; $ count = isset ( $ result [ 'count' ] ) ? $ result [ 'count' ] : $ urlComponents [ 'limit' ] ; $ pages = ceil ( $ count / $ limit ) ; for ( $ page = $ this -> page + 1 ; $ page <= $ pages ; ++ $ page ) { $ urlComponents [ 'query' ] [ 'start' ] = abs ( $ page - 1 ) * $ limit ; $ response = $ this -> client -> get ( $ url . http_build_query ( $ urlComponents [ 'query' ] , '' , '&' ) ) ; $ result = json_decode ( $ response -> getContent ( ) , true ) ; $ fullResult = array_merge ( $ fullResult , $ result [ $ valuesKey ] ) ; // We only wanted one, so stop now if ( $ this -> perPage !== null ) { break ; } } return $ fullResult ; }
Fetches all the results, using API version 1.0.

@param array  $result
@param string $valuesKey

@return array

@throws \RuntimeException
Fetches all the results using API version 1 . 0 .