diff --git a/src/Core/parse.php b/src/Core/parse.php index b2a88e6..baf6b85 100644 --- a/src/Core/parse.php +++ b/src/Core/parse.php @@ -31,7 +31,7 @@ function isLeaf(array $query): bool function convertToExplicit(array $query): array { return [ - LogicalOperator::AND => array_map(fn ($key) => [$key => $query[$key]], array_keys($query)), + LogicalOperator::AND => array_map(fn($key) => [$key => $query[$key]], array_keys($query)), ]; } diff --git a/src/Tools/Norm.php b/src/Tools/Norm.php index ab3cf0c..e8314b2 100644 --- a/src/Tools/Norm.php +++ b/src/Tools/Norm.php @@ -23,7 +23,7 @@ public function get(string $value): float if (isset($this->cache[$numTokens])) { return $this->cache[$numTokens]; } - + // Default function is 1/sqrt(x), weight makes that variable $norm = 1 / pow($numTokens, 0.5 * $this->weight); diff --git a/test/FuzzySearch/ObjectValuesTest.php b/test/FuzzySearch/ObjectValuesTest.php index cd2e604..665b299 100644 --- a/test/FuzzySearch/ObjectValuesTest.php +++ b/test/FuzzySearch/ObjectValuesTest.php @@ -27,17 +27,14 @@ class ObjectValuesTest extends TestCase public function testObjectsAreProcessed(): void { $fuse = new Fuse( - [ - new TestObject(["name" => "foo"]), - new TestObject(["name" => "bar"]), - ], + [new TestObject(['name' => 'foo']), new TestObject(['name' => 'bar'])], [ 'keys' => [ [ 'name' => 'name', 'getFn' => function ($document) { return $document->get('name'); - } + }, ], ], ], diff --git a/test/LogicalSearch/SearchTest.php b/test/LogicalSearch/SearchTest.php index 1b72637..4d03ea0 100644 --- a/test/LogicalSearch/SearchTest.php +++ b/test/LogicalSearch/SearchTest.php @@ -128,19 +128,19 @@ public function testSearchOrWithNestedEntries(): void public function testSearchWithLogicalOrWithSameQueryAcrossFieldsForWood(): void { $options = [ - 'keys' => ['title', 'author.lastName'] + 'keys' => ['title', 'author.lastName'], ]; $fuse = new Fuse(static::$books, $options); - + $query = [ '$or' => [ [ - 'title' => 'wood' + 'title' => 'wood', ], [ - 'author.lastName' => 'wood' - ] - ] + 'author.lastName' => 'wood', + ], + ], ]; $result = $fuse->search($query); diff --git a/test/ScoringTest.php b/test/ScoringTest.php index a03ab1f..4f381fb 100644 --- a/test/ScoringTest.php +++ b/test/ScoringTest.php @@ -9,17 +9,14 @@ class ScoringTest extends TestCase { - private static array $defaultList = [ - 'Stove', - 'My good friend Steve from college' - ]; + private static array $defaultList = ['Stove', 'My good friend Steve from college']; private static array $defaultOptions = []; - + private static function setupFuse($itemList = null, $overwriteOptions = []) { $list = $itemList ?? static::$defaultList; $options = array_merge(static::$defaultOptions, $overwriteOptions); - + return new Fuse($list, $options); } @@ -38,7 +35,7 @@ public function testIgnoreFieldNormOff() public function testIgnoreFieldNormOffAndFieldNormWeightDecreased() { - $fuse = $this::setupFuse(null, [ 'fieldNormWeight' => 0.15 ]); + $fuse = $this::setupFuse(null, ['fieldNormWeight' => 0.15]); $result = $fuse->search('Steve'); // we get a list of containing 2 items