From 8d0061d3dc46f124aee68f23ec90c61c1f3841a2 Mon Sep 17 00:00:00 2001 From: Jasper Zonneveld Date: Wed, 27 Mar 2024 11:43:40 +0100 Subject: [PATCH] style: fix (updated) code style --- src/Indexable.php | 4 ++-- src/ModelObserver.php | 15 +++++++-------- src/Search.php | 19 ++++++++----------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Indexable.php b/src/Indexable.php index bcfd5a6..170d4ee 100644 --- a/src/Indexable.php +++ b/src/Indexable.php @@ -32,7 +32,7 @@ public function indexedRecord() public function indexRecord() { - if (null === $this->indexedRecord) { + if ($this->indexedRecord === null) { $this->indexedRecord = new IndexedRecord(); $this->indexedRecord->indexable()->associate($this); } @@ -41,7 +41,7 @@ public function indexRecord() public function unIndexRecord() { - if (null !== $this->indexedRecord) { + if ($this->indexedRecord !== null) { $this->indexedRecord->delete(); } } diff --git a/src/ModelObserver.php b/src/ModelObserver.php index 6e18c7b..64c84da 100644 --- a/src/ModelObserver.php +++ b/src/ModelObserver.php @@ -14,7 +14,7 @@ class ModelObserver /** * Enable syncing for the given class. * - * @param string $class + * @param string $class */ public static function enableSyncingFor($class) { @@ -24,7 +24,7 @@ public static function enableSyncingFor($class) /** * Disable syncing for the given class. * - * @param string $class + * @param string $class */ public static function disableSyncingFor($class) { @@ -34,8 +34,7 @@ public static function disableSyncingFor($class) /** * Determine if syncing is disabled for the given class or model. * - * @param object|string $class - * + * @param object|string $class * @return bool */ public static function syncingDisabledFor($class) @@ -48,7 +47,7 @@ public static function syncingDisabledFor($class) /** * Handle the created event for the model. * - * @param \Illuminate\Database\Eloquent\Model $model + * @param \Illuminate\Database\Eloquent\Model $model */ public function created($model) { @@ -62,7 +61,7 @@ public function created($model) /** * Handle the updated event for the model. * - * @param \Illuminate\Database\Eloquent\Model $model + * @param \Illuminate\Database\Eloquent\Model $model */ public function updated($model) { @@ -72,7 +71,7 @@ public function updated($model) /** * Handle the deleted event for the model. * - * @param \Illuminate\Database\Eloquent\Model $model + * @param \Illuminate\Database\Eloquent\Model $model */ public function deleted($model) { @@ -86,7 +85,7 @@ public function deleted($model) /** * Handle the restored event for the model. * - * @param \Illuminate\Database\Eloquent\Model $model + * @param \Illuminate\Database\Eloquent\Model $model */ public function restored($model) { diff --git a/src/Search.php b/src/Search.php index bd56cad..b8ecd74 100644 --- a/src/Search.php +++ b/src/Search.php @@ -5,8 +5,7 @@ class Search implements SearchInterface { /** - * @param string $search - * + * @param string $search * @return \Illuminate\Database\Eloquent\Collection|\Swis\Laravel\Fulltext\IndexedRecord[] */ public function run($search) @@ -17,9 +16,8 @@ public function run($search) } /** - * @param string $search - * @param string $class - * + * @param string $search + * @param string $class * @return \Illuminate\Database\Eloquent\Collection|\Swis\Laravel\Fulltext\IndexedRecord[] */ public function runForClass($search, $class) @@ -31,8 +29,7 @@ public function runForClass($search, $class) } /** - * @param string $search - * + * @param string $search * @return \Illuminate\Database\Eloquent\Builder */ public function searchQuery($search) @@ -51,12 +48,12 @@ public function searchQuery($search) $contentWeight = str_replace(',', '.', (float) config('laravel-fulltext.weight.content', 1.0)); $query = IndexedRecord::query() - ->whereRaw('MATCH (indexed_title, indexed_content) AGAINST (? IN BOOLEAN MODE)', [$termsBool]) - ->orderByRaw( - '('.$titleWeight.' * (MATCH (indexed_title) AGAINST (?)) + + ->whereRaw('MATCH (indexed_title, indexed_content) AGAINST (? IN BOOLEAN MODE)', [$termsBool]) + ->orderByRaw( + '('.$titleWeight.' * (MATCH (indexed_title) AGAINST (?)) + '.$contentWeight.' * (MATCH (indexed_title, indexed_content) AGAINST (?)) ) DESC', - [$termsMatch, $termsMatch]) + [$termsMatch, $termsMatch]) ->limit(config('laravel-fulltext.limit-results')); if (config('laravel-fulltext.exclude_feature_enabled')) {