Get raw Twitter response
@param string $query 	'q' type of query
@param integer $count 	Define a number of search results
@return object
493313
public function makeRequest($query, $count)
	{

		try { 
 			
 			$response = $this->client->request('GET', self::$api_base.'1.1/search/tweets.json', [
			    'query' => ['q' => $query, 'count' => $count],
			    'headers' => [
			        'Authorization' => 'Bearer ' . $this->bearer_token
			    ]
			]);
  			
			$this->setStatusCode($response->getStatusCode());

			$response_body = json_decode($response->getBody());
 			$this->response = $response_body->statuses;
 
 		} catch (\Exception $e) {

			$this->setStatusCode($e->getCode());
			$this->setResponse($e->getMessage());

		}
	}
499093
public function runCount($query)
	{
		if (isset($this->stored_query_totals[md5(serialize($query))])) {
			return $this->stored_query_totals[md5(serialize($query))];
		}
		
		$query['terms'] = trim($query['terms']);
		if (isset($query['numericFilters'])) {
			$query['numericFilters'] = implode(',', $query['numericFilters']);
		}
		if (isset($query['facets'])) {
			$query['facets'] = implode(',', $query['facets']);
		}
		
		try {
			return array_get($this->getIndex()->search(array_get($query, 'terms'), array_get($query, 'query')), 'nbHits');
		} catch (\Exception $e) {
			return 0;
		}
	}
423858
function search_statuses( $q,  $count = 10)
	{
		$params = array();
		$params['q'] = $q;
		$params['count'] = $count;
		return $this->oauth->get( 'search/suggestions/statuses', $params );
	}
443640
public function command(array $query)
    {
        // Create command from query
        $command = $this->getCommand($query);

        try {
            $cursor = $this->getInstance()->executeCommand(
                $this->getParam('database'),
                $command
            );
            $response = $cursor->toArray();

        } catch (MongoException $e) {
            new Exception('Unable to execute command');
        }

        return $response ?? false;
    }
1153057
public function search($query, bool $full = false): stdClass
	{
		$res = $this->request('search/tweets', 'GET', is_array($query) ? $query : ['q' => $query]);
		return $full ? $res : $res->statuses;
	}
244960
public function findRaw($query, $type)
    {
        $response = $this->client->request(
            'GET',
            "/{$this->indexName}/{$type}/_search",
            new Message(
                array(
                    'Content-Type' => 'application/json',
                ),
                $query
            )
        );

        return $response;
    }
1233040
protected function build_query($count = false) {
        $sql = 'SELECT ';

        if ($count) {
            $sql .= 'COUNT(\'x\') ';
        } else {
            $sql .= implode(', ', $this->fields) . ' ';
        }

        $sql .= $this->from . ' ';
        $sql .= implode(' ', $this->joins) . ' ';

        if (!empty($this->where)) {
            $sql .= 'WHERE (' . implode(') AND (', $this->where) . ') ';
        }

        if (!$count && !empty($this->order)) {
            $sql .= 'ORDER BY ' . implode(', ', $this->order);
        }

        return $sql;
    }
102841
public function getItems($count = null, $start = 0)
    {
        $columns = [];

        foreach ($this->columns as $key => $value) {
            $columns[] = $this->applyTableAlias($value);
        }

        $builder = $this->connection->createQueryBuilder();
        $builder
            ->select(empty($columns) ? $this->applyTableAlias('*') : $columns)
            ->from($this->tableName, $this->tableAlias)
        ;

        $builder = $this->applyConditions($builder);
        $builder = $this->applyOrdering($builder);

        if (!is_null($count)) {
            $builder
                ->setMaxResults($count)
                ->setFirstResult($start)
            ;
        }

        $this->dispatcher->dispatch('onQueryDatabase', new QueryDatabaseEvent($this->entityClass, $builder));

        try {
            $rows = $builder
                ->execute()
                ->fetchAll(\PDO::FETCH_ASSOC)
            ;
        } catch (SyntaxErrorException $e) {
            throw new InvalidOperatorException($e->getMessage(), 0, $e);
        } catch (DBALException $e) {
            throw new EntityNotFoundException();
        }

        foreach ($this->patterns as $column => $pattern) {
            $column = $this->stripTableAlias($column);
            $rows   = array_filter(
                $rows,
                function ($row) use ($column, $pattern) {
                    return preg_match("~{$pattern}~", $row[$column]);
                }
            );
        }

        if (empty($rows)) {
            return [];
        }

        if (empty($this->columns)) {
            $rows = $this->castToEntity($rows);
        }

        if (count($this->columns) == 1 && $this->columns[0] != '*') {
            $result = [];

            foreach ($rows as $match) {
                $result[] = $match[$this->columns[0]];
            }

            return $result;
        }

        return array_values($rows);
    }
1155415
public function gadget($view = 'admin.faq.gadget', $count = 10)
    {

        if (User::hasRole('user')) {
            $this->faq->pushCriteria(new \Litepie\Litecms\Repositories\Criteria\FaqUserCriteria());
        }

        $faq = $this->faq->scopeQuery(function ($query) use ($count) {
            return $query->orderBy('id', 'DESC')->take($count);
        })->all();

        return view('faq::' . $view, compact('faq'))->render();
    }
760231
public function searchTweets($query, $count = 10)
	{	
		if ($this->bearer_token == null) {
			throw new \Exception('Incorrect token. You need to obtain correct Bearer token in order to make calls to the API. Check if your API keys are correct.');
		}

		$this->makeRequest($query, $count);
	}
1294525
public function count($query = [], $options = [])
    {
        try {
            // Handle legacy mode - limit and skip as second and third parameters, respectively
            if (! is_array($options)) {
                $limit = $options;
                $options = [];

                if ($limit !== null) {
                    $options['limit'] = (int) $limit;
                }

                if (func_num_args() > 2) {
                    $options['skip'] = (int) func_get_args()[2];
                }
            }

            return $this->collection->count(TypeConverter::fromLegacy($query), $options);
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e);
        }
    }
1217026
public function search($query, $lang = 'en', $limit = 10) 
    {    
        $client = new Client(); 

        $response = $client->get(self::API_ENDPOINT, [
            'query' => [
                'action' => 'wbsearchentities',
                'format' => 'json',
                'strictlanguage' => true,
                'language' => $lang,
                'uselang' => $lang,
                'search' => $query,
                'limit' => $limit,
                'props' => ''
            ]
        ]);

        $results = json_decode($response->getBody(), true);

        $data = isset($results['search']) ? $results['search'] : [];

        $collection = collect($data);

        $output = $collection->map(function($item) use ($lang) {
            return new SearchResult($item, $lang, 'api');
        });

        return $output;
    }
611230
public function getTopic($count = 1)
    {
        $respondent = $this->getRespondent();
        $patientId  = $respondent->getPatientNumber();
        if ($patientId) {
            if ($this->currentUser->areAllFieldsMaskedWhole('grs_first_name', 'grs_surname_prefix', 'grs_last_name')) {
                $for = sprintf($this->_('for respondent number %s'), $patientId);
            } else {
                $for = sprintf($this->_('for respondent number %s'), $patientId);
            }
            $for = ' ' . $for;
        } else {
            $for = '';
        }
        return $this->plural('episode of care', 'episodes of care', $count) . $for;
    }
1353367
public function chunk($callback, $count = 100)
    {
        if ($this->usePaginate) {
            return $this->buildData(false)->chunk($count)->each($callback);
        }

        $this->setSort();

        $this->queries->reject(function ($query) {
            return 'paginate' === $query['method'];
        })->each(function ($query) {
            $this->model = $this->model->{$query['method']}(...$query['arguments']);
        });

        return $this->model->chunk($count, $callback);
    }
289939
private function read($count) {
        $count = abs($count);

        if ($count > 0) {
            return fread($this->STREAM, $count);
        }

        return NULL;
    }
337492
protected function getRandomString($count)
    {
        // This string MUST stay FS safe, avoid special chars
        $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';
        $ret = '';
        $strlen = strlen($base);
        for ($i = 0; $i < $count; ++$i) {
            $ret .= $base[random_int(0, $strlen - 1)];
        }

        return $ret;
    }
1291066
public function search($query)
    {
        try {
            $request = $this->client->createRequest($query);
            $response = $this->executeRequest($request);
            $this->hasSearched = true;
            $this->responseCache = $response;
        } catch (HttpException $e) {
            $this->handleErrorResponses($e);
        }
        return $response;
    }