Count document into the index and then multiply it by the request cutoff frequency
to compute an absolute cutoff frequency limit (max numbre of doc).

@param RequestInterface $request The spellcheck request.

@return int
3493
private function getCutoffrequencyLimit(RequestInterface $request)
    {
        $indexStatsResponse = $this->client->indexStats($request->getIndex());
        $indexStats         = current($indexStatsResponse['indices']);
        $totalIndexedDocs = $indexStats['total']['docs']['count'];

        return $request->getCutoffFrequency() * $totalIndexedDocs;
    }
695295
protected function incrementLoginAttempts( Request $request )
	{
		UniversalBuilder::resolveClass( RateLimiter::class )->hit( $this->getThrottleKey( $request ) );
	}
663527
public function buildSearchRequest(RequestInterface $request)
    {
        $searchRequest = [
            'size' => $request->getSize(),
        ];

        if ($searchRequest['size'] > 0) {
            $searchRequest['sort'] = $this->getSortOrders($request);
            $searchRequest['from'] = $request->getFrom();
        }

        $query = $this->getRootQuery($request);
        if ($query) {
            $searchRequest['query'] = $query;
        }

        $filter = $this->getRootFilter($request);
        if ($filter) {
            $searchRequest['post_filter'] = $filter;
        }

        $aggregations = $this->getAggregations($request);
        if (!empty($aggregations)) {
            $searchRequest['aggregations'] = $aggregations;
        }

        return $searchRequest;
    }
601340
public function filterRequest(RequestInterface $request)
    {
        if ($this->pattern->matchRequest($request)) {
            $this->securityInterceptor->invoke();
            return true;
        }
        return false;
    }
466998
private function deleteVary(RequestInterface $request)
    {
        $key = $this->getVaryKey($request);
        $this->cache->delete($key);
    }
478546
public function parseRequest(Request $request)
    {
        try {
            $this->setPath($request->get('_route'));

            $this->setQuery($request->query->all());

            $this->setRouteParams($request->attributes->get('_route_params'));

            if ($request->get('page')) {
                $this->setCurrentPage((int)$request->get('page'));
            }

            if ($request->get('maxItems')) {
                $this->setNumberOfElementsPerPage((int)$request->get('maxItems'));
            }

        } catch (\Exception $e) {
            throw new \Exception ('The request provided is not a valid Request Object');
        }

        return $this;
    }
106025
public function applyToRequest(RequestInterface $request)
    {
        $body = $this->streamFactory->createStream((string) $this->queryHelper);

        return $request
            ->withBody($body)
            ->withHeader('Content-Type', 'application/x-www-form-urlencoded');
    }
1251301
function match(RequestInterface $request)
    {
        if (strtoupper($request->getMethod()) !== $this->getMethod())
            return false;

        return parent::match($request);
    }
110930
protected static function getKey(RequestInterface $request)
    {
        // Generate headerline for the cache key. X- headers are ignored except those included in the Vary
        $vary = array_flip($request->getHeader('Vary'));
        $headerLine = implode('', array_map(
            [$request, 'getHeaderLine'],
            array_filter(
                array_keys($request->getHeaders()),
                function ($header) use ($vary) {
                    return (0 !== stripos($header, 'x-')
                        || array_key_exists($header, $vary)
                    );
                }
            )
        ));

        return $request->getMethod().'-'.$request->getUri().'-'.md5($headerLine);
    }
1355326
private function parseFilters(TableInterface $table, Request $request)
    {
        $filters = [];

        $queryParams = $request->get($table->getFormId());

        foreach ($table->getAllFilters() as $filter) {
            if (isset($queryParams[$filter->getName()])) {
                $searchParamRaw = trim($queryParams[$filter->getName()]);
                if ($searchParamRaw != '') {
                    $filters[$filter->getName()] = $searchParamRaw;
                }
            }
        }

        return $filters;
    }
989759
public function cgetAction(Request $request)
    {
        $locale = $this->getLocale($request);

        // if the type parameter is falsy, assign NULL to $type
        $type = $request->query->get('type', null) ?: null;

        $idsString = $request->get('ids');

        if ($idsString) {
            $ids = explode(',', $idsString);
            $snippets = $this->snippetRepository->getSnippetsByUuids($ids, $locale);
            $total = count($snippets);
        } else {
            $snippets = $this->snippetRepository->getSnippets(
                $locale,
                $type,
                $this->listRestHelper->getOffset(),
                $this->listRestHelper->getLimit(),
                $this->listRestHelper->getSearchPattern(),
                $this->listRestHelper->getSortColumn(),
                $this->listRestHelper->getSortOrder()
            );

            $total = $this->snippetRepository->getSnippetsAmount(
                $locale,
                $type,
                $this->listRestHelper->getSearchPattern(),
                $this->listRestHelper->getSortColumn(),
                $this->listRestHelper->getSortOrder()
            );
        }

        $data = new ListRepresentation(
            $snippets,
            'snippets',
            'get_snippets',
            $request->query->all(),
            $this->listRestHelper->getPage(),
            $this->listRestHelper->getLimit(),
            $total
        );

        return $this->viewHandler->handle(View::create($data));
    }
378853
private function getOffset(Request $request, $limit)
    {
        $page = $request->get('page', 1);

        return (null !== $limit) ? $limit * ($page - 1) : 0;
    }
948968
public function index(Request $request)
    {
        // handle permission
//        list($request, $filters) = $this->handlePermission(__FUNCTION__, $request);

        // create response model
        $response = new ResponseModel();

        $pageSize = $this->DEFAULT_RESULT_PER_PAGE;

        $pageNumber = 1;

        //set default pagination

        //set page size
        if (!isset($request->toArray()['page']['size'])) {
            $pageSize = $this->DEFAULT_RESULT_PER_PAGE;
        } elseif (($request->get('page')['size']) == 0) {
            $pageSize = $this->DEFAULT_RESULT_PER_PAGE;
        } else {
            $pageSize = $request->get('page')['size'];
        }

        //set page number
        if (!isset($request->get('page')['number'])) {
            $pageNumber = $this->DEFAULT_PAGE_NUMBER;
        } elseif (($request->get('page')['number']) == 0) {
            $pageNumber = $this->DEFAULT_PAGE_NUMBER;
        } else {
            $pageNumber = $request->get('page')['number'];
        }
        $request['page'] = $pageNumber;


        //set default ordering
        if (isset($request->toArray()['order_by'])) {
            if (is_null($request['order_by'])) {
                $request['order_by'] = "{\"field\":\"id\",\"operator\":\"Desc\"}";
            }
        }

        $validationErrors = $this->checkRequestValidation($request, $this->indexValidateArray);
        if ($validationErrors != null) {
            if (env('APP_DEBUG', false)) {
                $response->setData(collect($validationErrors->toArray()));
            }
            $response->setMessage($this->getTrans(__FUNCTION__, 'validation_failed'));
            $response->setStatus(false);
            $response->setError(99);
            return SmartResponse::response($response);
        }

        try {
            $data = $request->get('query') != null ?
                $this->model
                    ->whereKey(collect($this->model
                        ->search(($request->get('query')))
                        ->raw())->get('ids')) :
                $this->model;

            if (array_key_exists('file', $request->toArray())) {
                //TODO add relation on top if here and create a tree flatter array in array helper
                //return (new ExcelHelper())->setOptions([
                //    'store_format' => $request->get('file') == null ? 'xls' : $request->get('file'),
                //    'download_format' => $request->get('file') == null ? 'xls' : $request->get('file'),
                //])->table($data->get()->toArray())->createExcelFile()->download();
            }

            // load relations
            if (count($this->indexLoad) > 0) {
                $data = $data->with($this->indexLoad);
            }

            // filters by
            if (!is_null($request->get('filters'))) {
                $data = (new QueryHelper())->deepFilter($data, (new RequestHelper())->getCollectFromJson($request['filters']));
            }

            // order by
            if (!is_null($request->get('order_by'))) {
                $data = (new QueryHelper())->orderBy($data, (new RequestHelper())->getCollectFromJson($request['order_by']));
            }

            // return response
            $response->setData(collect($data->paginate($pageSize)));
            $response->setMessage($this->getTrans('index', 'successful'));
            return SmartResponse::response($response);

        } catch (QueryException $exception) {

            // return response
            $response->setData(collect($exception->getMessage()));
            $response->setError($exception->getCode());
            $response->setMessage($this->getTrans('index', 'failed'));
            $response->setStatus(false);
            return SmartResponse::response($response);
        }
    }
307094
protected function getTotalChunksFromRequest(Request $request)
    {
        if (!$request->get(static::KEY_CHUNK_SIZE)) {
            return 0;
        }

        return intval(
            ceil($request->get(static::KEY_TOTAL_SIZE) / $request->get(static::KEY_CHUNK_SIZE))
        );
    }
48063
public function getCensusHeaderAction(ServerRequestInterface $request): ResponseInterface
    {
        $census = $request->get('census');

        $html = $this->censusTableHeader(new $census());

        return response($html);
    }
903158
public function numberofshippedorderitemsAction(Request $request)
    {
        $orderId = $request->get('orderId');
        $sum = $this->getManager()->getSumOfShippedItemsByOrderId($orderId);
        return $this->handleView($this->view($sum, 200));
    }
615275
public function fetch(RequestInterface $request)
    {
        /** @var int|null $maxAge */
        $maxAge = null;

        if ($request->hasHeader('Cache-Control')) {
            $reqCacheControl = new KeyValueHttpHeader($request->getHeader('Cache-Control'));
            if ($reqCacheControl->has('no-cache')) {
                // Can't return cache
                return null;
            }

            $maxAge = $reqCacheControl->get('max-age', null);
        } elseif ($request->hasHeader('Pragma')) {
            $pragma = new KeyValueHttpHeader($request->getHeader('Pragma'));
            if ($pragma->has('no-cache')) {
                // Can't return cache
                return null;
            }
        }

        $cache = $this->storage->fetch($this->getCacheKey($request));
        if ($cache !== null) {
            $varyHeaders = $cache->getVaryHeaders();

            // vary headers exist from a previous response, check if we have a cache that matches those headers
            if (!$varyHeaders->isEmpty()) {
                $cache = $this->storage->fetch($this->getCacheKey($request, $varyHeaders));

                if (!$cache) {
                    return null;
                }
            }

            if ((string)$cache->getOriginalRequest()->getUri() !== (string)$request->getUri()) {
                return null;
            }

            if ($maxAge !== null) {
                if ($cache->getAge() > $maxAge) {
                    // Cache entry is too old for the request requirements!
                    return null;
                }
            }

            if (!$cache->isVaryEquals($request)) {
                return null;
            }
        }

        return $cache;
    }