|
1
|
|
|
<?php |
|
2
|
|
|
/******************************************************************************* |
|
3
|
|
|
* This file is part of the GraphQL Bundle package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) YnloUltratech <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
******************************************************************************/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Ynlo\GraphQLBundle\Model\Filter; |
|
12
|
|
|
|
|
13
|
|
|
use Ynlo\GraphQLBundle\Annotation as GraphQL; |
|
14
|
|
|
use Ynlo\GraphQLBundle\Type\NumberComparisonOperatorType; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @GraphQL\InputObjectType( |
|
18
|
|
|
* description="Create float comparison expression to compare values. |
|
19
|
|
|
|
|
20
|
|
|
#### Example: |
|
21
|
|
|
|
|
22
|
|
|
To select values greater than or equal to 10.00 |
|
23
|
|
|
```` |
|
24
|
|
|
op: GTE |
|
25
|
|
|
value: 10.00 |
|
26
|
|
|
```` |
|
27
|
|
|
|
|
28
|
|
|
or range of values |
|
29
|
|
|
```` |
|
30
|
|
|
op: BETWEEN |
|
31
|
|
|
value: 10.00 |
|
32
|
|
|
maxValue: 20.00 |
|
33
|
|
|
```` |
|
34
|
|
|
") |
|
35
|
|
|
*/ |
|
36
|
|
|
class FloatComparisonExpression |
|
37
|
|
|
{ |
|
38
|
|
|
/** |
|
39
|
|
|
* @var string|null |
|
40
|
|
|
* |
|
41
|
|
|
* @GraphQL\Field(type="NumberComparisonOperator!", description="Comparison operator") |
|
42
|
|
|
*/ |
|
43
|
|
|
private $op = NumberComparisonOperatorType::EQ; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var float|null |
|
47
|
|
|
* |
|
48
|
|
|
* @GraphQL\Field(type="float!", description="Number value to compare") |
|
49
|
|
|
*/ |
|
50
|
|
|
private $value; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var float|null |
|
54
|
|
|
* |
|
55
|
|
|
* @GraphQL\Field(type="float", description="Max value to compare when use `BETWEEN`") |
|
56
|
|
|
*/ |
|
57
|
|
|
private $maxValue; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return null|string |
|
61
|
|
|
*/ |
|
62
|
7 |
|
public function getOp(): ?string |
|
63
|
|
|
{ |
|
64
|
7 |
|
return $this->op; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param null|string $op |
|
69
|
|
|
*/ |
|
70
|
7 |
|
public function setOp(?string $op): void |
|
71
|
|
|
{ |
|
72
|
7 |
|
$this->op = $op; |
|
73
|
7 |
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return null|float |
|
77
|
|
|
*/ |
|
78
|
7 |
|
public function getValue(): ?float |
|
79
|
|
|
{ |
|
80
|
7 |
|
return $this->value; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param null|float $value |
|
85
|
|
|
*/ |
|
86
|
9 |
|
public function setValue(?float $value): void |
|
87
|
|
|
{ |
|
88
|
9 |
|
$this->value = $value; |
|
89
|
9 |
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return float|null |
|
93
|
|
|
*/ |
|
94
|
1 |
|
public function getMaxValue(): ?float |
|
95
|
|
|
{ |
|
96
|
1 |
|
return $this->maxValue; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param float|null $maxValue |
|
101
|
|
|
*/ |
|
102
|
1 |
|
public function setMaxValue(?float $maxValue): void |
|
103
|
|
|
{ |
|
104
|
1 |
|
$this->maxValue = $maxValue; |
|
105
|
1 |
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|