-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathWeight.php
More file actions
48 lines (33 loc) · 848 Bytes
/
Weight.php
File metadata and controls
48 lines (33 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php declare(strict_types = 1);
namespace Spameri\ElasticQuery\FunctionScore\ScoreFunction;
class Weight implements \Spameri\ElasticQuery\FunctionScore\FunctionScoreInterface
{
private float $weight;
private \Spameri\ElasticQuery\Query\LeafQueryInterface $leafQuery;
public function __construct(
float $weight,
\Spameri\ElasticQuery\Query\LeafQueryInterface $leafQuery
) {
$this->weight = $weight;
$this->leafQuery = $leafQuery;
}
public function key(): string
{
return 'weight_' . $this->leafQuery->key();
}
public function weight(): float
{
return $this->weight;
}
public function leafQuery(): \Spameri\ElasticQuery\Query\LeafQueryInterface
{
return $this->leafQuery;
}
public function toArray(): array
{
return [
'weight' => $this->weight,
'filter' => $this->leafQuery->toArray(),
];
}
}