Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit 50b6002

Browse files
Merge pull request #24 from devloopsnet/analysis-orAVep
Apply fixes from StyleCI
2 parents 9f5fa05 + 59d6863 commit 50b6002

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

src/Engines/TypesenseSearchEngine.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function update($models): void
8282
$models->each->pushSoftDeleteMetadata();
8383
}
8484

85-
$this->typesense->importDocuments($collection, $models->map(fn($m) => $m->toSearchableArray())
85+
$this->typesense->importDocuments($collection, $models->map(fn ($m) => $m->toSearchableArray())
8686
->toArray());
8787
}
8888

@@ -104,10 +104,10 @@ public function delete($models): void
104104
/**
105105
* @param \Laravel\Scout\Builder $builder
106106
*
107-
* @return mixed
108107
* @throws \Typesense\Exceptions\TypesenseClientError
109-
*
110108
* @throws \Http\Client\Exception
109+
*
110+
* @return mixed
111111
*/
112112
public function search(Builder $builder): mixed
113113
{
@@ -119,10 +119,10 @@ public function search(Builder $builder): mixed
119119
* @param int $perPage
120120
* @param int $page
121121
*
122-
* @return mixed
123122
* @throws \Typesense\Exceptions\TypesenseClientError
124-
*
125123
* @throws \Http\Client\Exception
124+
*
125+
* @return mixed
126126
*/
127127
public function paginate(Builder $builder, $perPage, $page): mixed
128128
{
@@ -139,13 +139,13 @@ public function paginate(Builder $builder, $perPage, $page): mixed
139139
private function buildSearchParams(Builder $builder, int $page, int $perPage): array
140140
{
141141
$params = [
142-
'q' => $builder->query,
143-
'query_by' => implode(',', $builder->model->typesenseQueryBy()),
144-
'filter_by' => $this->filters($builder),
145-
'per_page' => $perPage,
146-
'page' => $page,
147-
'highlight_start_tag' => $this->startTag,
148-
'highlight_end_tag' => $this->endTag,
142+
'q' => $builder->query,
143+
'query_by' => implode(',', $builder->model->typesenseQueryBy()),
144+
'filter_by' => $this->filters($builder),
145+
'per_page' => $perPage,
146+
'page' => $page,
147+
'highlight_start_tag' => $this->startTag,
148+
'highlight_end_tag' => $this->endTag,
149149
];
150150

151151
if ($this->limitHits > 0) {
@@ -213,10 +213,10 @@ private function parseOrderBy(array $orders): string
213213
* @param \Laravel\Scout\Builder $builder
214214
* @param array $options
215215
*
216-
* @return mixed
217216
* @throws \Typesense\Exceptions\TypesenseClientError
218-
*
219217
* @throws \Http\Client\Exception
218+
*
219+
* @return mixed
220220
*/
221221
protected function performSearch(Builder $builder, array $options = []): mixed
222222
{
@@ -240,8 +240,8 @@ protected function filters(Builder $builder): string
240240
{
241241
return collect($builder->wheres)
242242
->map([
243-
$this,
244-
'parseFilters',
243+
$this,
244+
'parseFilters',
245245
])
246246
->values()
247247
->implode(' && ');
@@ -311,7 +311,7 @@ public function map(Builder $builder, $results, $model): \Illuminate\Database\El
311311
*/
312312
public function getTotalCount($results): int
313313
{
314-
return (int)($results['found'] ?? 0);
314+
return (int) ($results['found'] ?? 0);
315315
}
316316

317317
/**
@@ -345,7 +345,7 @@ protected function usesSoftDelete($model): bool
345345
*/
346346
public function lazyMap(Builder $builder, $results, $model): LazyCollection
347347
{
348-
if ((int)($results['found'] ?? 0) === 0) {
348+
if ((int) ($results['found'] ?? 0) === 0) {
349349
return LazyCollection::make($model->newCollection());
350350
}
351351

@@ -371,9 +371,9 @@ public function lazyMap(Builder $builder, $results, $model): LazyCollection
371371
* @param string $name
372372
* @param array $options
373373
*
374-
* @return void
375374
* @throws \Exception
376375
*
376+
* @return void
377377
*/
378378
public function createIndex($name, array $options = []): void
379379
{
@@ -465,10 +465,10 @@ public function limitHits(int $limitHits): static
465465
public function orderByLocation(string $column, float $lat, float $lng, string $direction): static
466466
{
467467
$this->locationOrderBy = [
468-
'column' => $column,
469-
'lat' => $lat,
470-
'lng' => $lng,
471-
'direction' => $direction,
468+
'column' => $column,
469+
'lat' => $lat,
470+
'lng' => $lng,
471+
'direction' => $direction,
472472
];
473473

474474
return $this;
@@ -477,11 +477,11 @@ public function orderByLocation(string $column, float $lat, float $lng, string $
477477
/**
478478
* @param string $name
479479
*
480-
* @return array
481480
* @throws \Typesense\Exceptions\ObjectNotFound
482481
* @throws \Typesense\Exceptions\TypesenseClientError
483-
*
484482
* @throws \Http\Client\Exception
483+
*
484+
* @return array
485485
*/
486486
public function deleteIndex($name): array
487487
{

src/Typesense.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public function getClient(): Client
4343
/**
4444
* @param $model
4545
*
46-
* @return \Typesense\Collection
4746
* @throws \Typesense\Exceptions\TypesenseClientError
48-
*
4947
* @throws \Http\Client\Exception
48+
*
49+
* @return \Typesense\Collection
5050
*/
5151
private function getOrCreateCollectionFromModel($model): Collection
5252
{
@@ -67,10 +67,10 @@ private function getOrCreateCollectionFromModel($model): Collection
6767
/**
6868
* @param $model
6969
*
70-
* @return \Typesense\Collection
7170
* @throws \Typesense\Exceptions\TypesenseClientError
72-
*
7371
* @throws \Http\Client\Exception
72+
*
73+
* @return \Typesense\Collection
7474
*/
7575
public function getCollectionIndex($model): Collection
7676
{
@@ -81,11 +81,11 @@ public function getCollectionIndex($model): Collection
8181
* @param \Typesense\Collection $collectionIndex
8282
* @param $array
8383
*
84-
* @return \Devloops\LaravelTypesense\Classes\TypesenseDocumentIndexResponse
8584
* @throws \Typesense\Exceptions\ObjectNotFound
8685
* @throws \Typesense\Exceptions\TypesenseClientError
87-
*
8886
* @throws \Http\Client\Exception
87+
*
88+
* @return \Devloops\LaravelTypesense\Classes\TypesenseDocumentIndexResponse
8989
*/
9090
public function upsertDocument(Collection $collectionIndex, $array): TypesenseDocumentIndexResponse
9191
{
@@ -113,18 +113,18 @@ public function upsertDocument(Collection $collectionIndex, $array): TypesenseDo
113113
* @param \Typesense\Collection $collectionIndex
114114
* @param $modelId
115115
*
116-
* @return array
117116
* @throws \Typesense\Exceptions\ObjectNotFound
118117
* @throws \Typesense\Exceptions\TypesenseClientError
119-
*
120118
* @throws \Http\Client\Exception
119+
*
120+
* @return array
121121
*/
122122
public function deleteDocument(Collection $collectionIndex, $modelId): array
123123
{
124124
/**
125125
* @var $document Document
126126
*/
127-
$document = $collectionIndex->getDocuments()[(string)$modelId] ?? null;
127+
$document = $collectionIndex->getDocuments()[(string) $modelId] ?? null;
128128
if ($document === null) {
129129
throw new ObjectNotFound();
130130
}
@@ -136,10 +136,10 @@ public function deleteDocument(Collection $collectionIndex, $modelId): array
136136
* @param \Typesense\Collection $collectionIndex
137137
* @param array $query
138138
*
139-
* @return array
140139
* @throws \Typesense\Exceptions\TypesenseClientError
141-
*
142140
* @throws \Http\Client\Exception
141+
*
142+
* @return array
143143
*/
144144
public function deleteDocuments(Collection $collectionIndex, array $query): array
145145
{
@@ -152,11 +152,11 @@ public function deleteDocuments(Collection $collectionIndex, array $query): arra
152152
* @param $documents
153153
* @param string $action
154154
*
155-
* @return \Illuminate\Support\Collection
156155
* @throws \JsonException
157156
* @throws \Typesense\Exceptions\TypesenseClientError
158-
*
159157
* @throws \Http\Client\Exception
158+
*
159+
* @return \Illuminate\Support\Collection
160160
*/
161161
public function importDocuments(Collection $collectionIndex, $documents, string $action = 'upsert'): \Illuminate\Support\Collection
162162
{
@@ -173,11 +173,11 @@ public function importDocuments(Collection $collectionIndex, $documents, string
173173
/**
174174
* @param string $collectionName
175175
*
176-
* @return array
177176
* @throws \Typesense\Exceptions\ObjectNotFound
178177
* @throws \Typesense\Exceptions\TypesenseClientError
179-
*
180178
* @throws \Http\Client\Exception
179+
*
180+
* @return array
181181
*/
182182
public function deleteCollection(string $collectionName): array
183183
{

0 commit comments

Comments
 (0)