File tree Expand file tree Collapse file tree 9 files changed +31
-64
lines changed
Expand file tree Collapse file tree 9 files changed +31
-64
lines changed Original file line number Diff line number Diff line change 99class Histogram implements LeafAggregationInterface
1010{
1111
12- /**
13- * @var string
14- */
15- private $ field ;
16-
17- /**
18- * @var int
19- */
20- private $ interval ;
12+ private string $ field ;
13+
14+ private int $ interval ;
2115
2216
2317 public function __construct (
Original file line number Diff line number Diff line change @@ -49,11 +49,7 @@ public function get(
4949 string $ key
5050 ): ?\Spameri \ElasticQuery \Entity \EntityInterface
5151 {
52- if (isset ($ this ->collection [$ key ])) {
53- return $ this ->collection [$ key ];
54- }
55-
56- return NULL ;
52+ return $ this ->collection [$ key ] ?? NULL ;
5753 }
5854
5955
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public function getType(): string
1717 public function toArray (): array
1818 {
1919 return [
20- $ this ->getType ()
20+ $ this ->getType (),
2121 ];
2222 }
2323
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public function getType(): string
1717 public function toArray (): array
1818 {
1919 return [
20- $ this ->getType ()
20+ $ this ->getType (),
2121 ];
2222 }
2323
Original file line number Diff line number Diff line change 99class Exists implements LeafQueryInterface
1010{
1111
12- /**
13- * @var string
14- */
15- private $ field ;
12+ private string $ field ;
1613
1714
1815 public function __construct (
Original file line number Diff line number Diff line change @@ -94,11 +94,17 @@ public function toArray(): array
9494 ];
9595
9696 if ($ this ->gte !== NULL ) {
97- $ array ['range ' ][$ this ->field ]['gte ' ] = $ this ->gte instanceof \DateTimeInterface ? $ this ->gte ->format ('Y-m-d H:i:s ' ) : $ this ->gte ;
97+ $ array ['range ' ][$ this ->field ]['gte ' ] =
98+ $ this ->gte instanceof \DateTimeInterface
99+ ? $ this ->gte ->format ('Y-m-d H:i:s ' )
100+ : $ this ->gte ;
98101 }
99102
100103 if ($ this ->lte !== NULL ) {
101- $ array ['range ' ][$ this ->field ]['lte ' ] = $ this ->lte instanceof \DateTimeInterface ? $ this ->lte ->format ('Y-m-d H:i:s ' ) : $ this ->lte ;
104+ $ array ['range ' ][$ this ->field ]['lte ' ] =
105+ $ this ->lte instanceof \DateTimeInterface
106+ ? $ this ->lte ->format ('Y-m-d H:i:s ' )
107+ : $ this ->lte ;
102108 }
103109
104110 return $ array ;
Original file line number Diff line number Diff line change 22
33namespace Spameri \ElasticQuery \Query ;
44
5-
65/**
76 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
87 */
98class Term implements LeafQueryInterface
109{
1110
12- /**
13- * @var string
14- */
15- private $ field ;
11+ private string $ field ;
1612
1713 /**
18- * @var string
14+ * @var string|int|bool|float
1915 */
2016 private $ query ;
2117
22- /**
23- * @var float
24- */
25- private $ boost ;
18+ private float $ boost ;
2619
2720
21+ /**
22+ * @param string|int|bool|float $query
23+ */
2824 public function __construct (
2925 string $ field
30- , string $ query
26+ , $ query
3127 , float $ boost = 1.0
3228 )
3329 {
@@ -45,17 +41,14 @@ public function key(): string
4541
4642 public function toArray (): array
4743 {
48- // phpcs:ignore SlevomatCodingStandard.Variables.UselessVariable
49- $ array = [
44+ return [
5045 'term ' => [
5146 $ this ->field => [
5247 'value ' => $ this ->query ,
5348 'boost ' => $ this ->boost ,
5449 ],
5550 ],
5651 ];
57-
58- return $ array ;
5952 }
6053
6154}
Original file line number Diff line number Diff line change 99class Terms implements LeafQueryInterface
1010{
1111
12- /**
13- * @var string
14- */
15- private $ field ;
12+ private string $ field ;
1613
1714 /**
18- * @var array
15+ * @var array<string|int|bool|float>
1916 */
20- private $ query ;
17+ private array $ query ;
2118
22- /**
23- * @var float
24- */
25- private $ boost ;
19+ private float $ boost ;
2620
2721
2822 public function __construct (
Original file line number Diff line number Diff line change 22
33namespace Spameri \ElasticQuery \Query ;
44
5-
65/**
76 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
87 */
98class WildCard implements LeafQueryInterface
109{
1110
12- /**
13- * @var string
14- */
15- private $ field ;
11+ private string $ field ;
1612
17- /**
18- * @var string
19- */
20- private $ query ;
13+ private string $ query ;
2114
22- /**
23- * @var float
24- */
25- private $ boost ;
15+ private float $ boost ;
2616
2717
2818 public function __construct (
@@ -45,17 +35,14 @@ public function key(): string
4535
4636 public function toArray (): array
4737 {
48- // phpcs:ignore SlevomatCodingStandard.Variables.UselessVariable
49- $ array = [
38+ return [
5039 'wildcard ' => [
5140 $ this ->field => [
5241 'value ' => $ this ->query ,
5342 'boost ' => $ this ->boost ,
5443 ],
5544 ],
5645 ];
57-
58- return $ array ;
5946 }
6047
6148}
You can’t perform that action at this time.
0 commit comments