Skip to content

Commit

Permalink
chore: format code with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
loilo committed Sep 17, 2023
1 parent 21b4fa9 commit 46d404c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Core/parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Norm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
7 changes: 2 additions & 5 deletions test/FuzzySearch/ObjectValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
},
],
],
],
Expand Down
12 changes: 6 additions & 6 deletions test/LogicalSearch/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
11 changes: 4 additions & 7 deletions test/ScoringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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
Expand Down

0 comments on commit 46d404c

Please sign in to comment.