Larabros\Elogram\Http\Clients\AbstractAdapter::paginate PHP Method

paginate() public method

{@inheritDoc}
public paginate ( Response $response, $limit = null )
$response Larabros\Elogram\Http\Response
    public function paginate(Response $response, $limit = null)
    {
        // If there's nothing to paginate, return response as-is
        if (!$response->hasPages() || $limit === 0) {
            return $response;
        }
        $next = $this->request('GET', $response->nextUrl());
        $merged = $response->merge($next);
        // If ``$limit`` is not set then call itself indefinitely
        if ($limit === null) {
            return $this->paginate($merged);
        }
        // If ``$limit`` is set, call itself while decrementing it each time
        $limit--;
        return $this->paginate($merged, $limit);
    }