RangeQuery   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 105
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A to() 0 5 1
A gte() 0 5 1
A gt() 0 5 1
A __construct() 0 3 1
A jsonSerialize() 0 5 1
A from() 0 5 1
A lte() 0 5 1
A format() 0 5 1
A lt() 0 5 1
1
<?php
2
3
namespace olvlvl\ElasticsearchDSL\Query\Term;
4
5
use olvlvl\ElasticsearchDSL\Query\Option\BoostOption;
6
use olvlvl\ElasticsearchDSL\Query\Option\HasBoostOption;
7
use olvlvl\ElasticsearchDSL\Query\QueryAbstract;
8
9
/**
10
 * @property mixed|null $gte
11
 * @property mixed|null $gt
12
 * @property mixed|null $lte
13
 * @property mixed|null $lt
14
 *
15
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html
16
 */
17
class RangeQuery extends QueryAbstract implements HasBoostOption
18
{
19
	use BoostOption;
20
21
	const NAME = 'range';
22
23
	/**
24
	 * @var string
25
	 */
26
	private $field;
27
28
	public function __construct(string $field)
29
	{
30
		$this->field = $field;
31
	}
32
33
	/**
34
	 * @param mixed|null $value
35
	 *
36
	 * @return $this
37
	 */
38
	public function from($value = null)
39
	{
40
		$this->options[__FUNCTION__] = $value;
41
42
		return $this;
43
	}
44
45
	/**
46
	 * @param mixed|null $value
47
	 *
48
	 * @return $this
49
	 */
50
	public function to($value = null)
51
	{
52
		$this->options[__FUNCTION__] = $value;
53
54
		return $this;
55
	}
56
57
	/**
58
	 * @param mixed|null $value
59
	 *
60
	 * @return $this
61
	 */
62
	public function gte($value = null)
63
	{
64
		$this->options[__FUNCTION__] = $value;
65
66
		return $this;
67
	}
68
69
	/**
70
	 * @param mixed|null $value
71
	 *
72
	 * @return $this
73
	 */
74
	public function gt($value = null)
75
	{
76
		$this->options[__FUNCTION__] = $value;
77
78
		return $this;
79
	}
80
81
	/**
82
	 * @param mixed|null $value
83
	 *
84
	 * @return $this
85
	 */
86
	public function lte($value = null)
87
	{
88
		$this->options[__FUNCTION__] = $value;
89
90
		return $this;
91
	}
92
93
	/**
94
	 * @param mixed|null $value
95
	 *
96
	 * @return $this
97
	 */
98
	public function lt($value = null)
99
	{
100
		$this->options[__FUNCTION__] = $value;
101
102
		return $this;
103
	}
104
105
	/**
106
	 * @param string $format
107
	 *
108
	 * @return $this
109
	 */
110
	public function format(string $format)
111
	{
112
		$this->options[__FUNCTION__] = $format;
113
114
		return $this;
115
	}
116
117
	public function jsonSerialize()
118
	{
119
		return [
120
			self::NAME => [
121
				$this->field => parent::jsonSerialize()
122
			]
123
		];
124
	}
125
}
126