@@ -16,7 +16,7 @@ |
||
16 | 16 | * @param LogicalFilter $filter |
17 | 17 | * @param Iterable $data_to_filter |
18 | 18 | */ |
19 | - public function apply( LogicalFilter $filter, $tree_to_filter, $options=[] ); |
|
19 | + public function apply(LogicalFilter $filter, $tree_to_filter, $options = []); |
|
20 | 20 | |
21 | 21 | public function validateRule($field, $operator, $value, $row, array $path, $all_operands, $options); |
22 | 22 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | /** |
18 | 18 | */ |
19 | - public function __construct( callable $rule_validator ) |
|
19 | + public function __construct(callable $rule_validator) |
|
20 | 20 | { |
21 | 21 | $this->rule_validator = $rule_validator; |
22 | 22 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function validateRule($field, $operator, $value, $row, array $path, $all_operands, $options) |
27 | 27 | { |
28 | - return call_user_func_array( $this->rule_validator, get_defined_vars() ); |
|
28 | + return call_user_func_array($this->rule_validator, get_defined_vars()); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /**/ |
@@ -34,7 +34,7 @@ |
||
34 | 34 | /** |
35 | 35 | * @param LogicalFilter $filter |
36 | 36 | */ |
37 | - public function convert( LogicalFilter $filter ); |
|
37 | + public function convert(LogicalFilter $filter); |
|
38 | 38 | |
39 | 39 | /**/ |
40 | 40 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | foreach ($operandsByOperator as $operator => $operandsOfOperator) { |
39 | 39 | if (count($operandsOfOperator) != 1) { |
40 | 40 | throw new \RuntimeException( |
41 | - "Once a logical filter is simplified, there MUST be " |
|
41 | + "Once a logical filter is simplified, there MUST be " |
|
42 | 42 | ."no more than one operand by operator instead of for '$field' / '$operator': " |
43 | 43 | .var_export($operandsOfOperator, true) |
44 | 44 | ); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @param LogicalFilter $filter |
20 | 20 | */ |
21 | - public function convert( LogicalFilter $filter ) |
|
21 | + public function convert(LogicalFilter $filter) |
|
22 | 22 | { |
23 | 23 | $rootOr = $filter->simplify(['force_logical_core' => true])->getRules(); |
24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | return $this; |
28 | 28 | } |
29 | 29 | |
30 | - if ( ! $rootOr->hasSolution()) { |
|
30 | + if (!$rootOr->hasSolution()) { |
|
31 | 31 | return $this; |
32 | 32 | } |
33 | 33 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | ); |
46 | 46 | } |
47 | 47 | |
48 | - $operandsByFields[ $field ][ $operator ] = $operandsOfOperator[0]; |
|
48 | + $operandsByFields[$field][$operator] = $operandsOfOperator[0]; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function onOpenOr() |
32 | 32 | { |
33 | - call_user_func( $this->callbacks[ __FUNCTION__ ] ); |
|
33 | + call_user_func($this->callbacks[__FUNCTION__]); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | */ |
38 | 38 | public function onCloseOr() |
39 | 39 | { |
40 | - call_user_func( $this->callbacks[ __FUNCTION__ ] ); |
|
40 | + call_user_func($this->callbacks[__FUNCTION__]); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function onAndPossibility($field, $operator, $operand, array $allOperandsByField) |
48 | 48 | { |
49 | 49 | call_user_func( |
50 | - $this->callbacks[ __FUNCTION__ ], |
|
50 | + $this->callbacks[__FUNCTION__], |
|
51 | 51 | $field, |
52 | 52 | $operator, |
53 | 53 | $operand, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | // https://www.elastic.co/guide/en/elasticsearch/guide/current/_dealing_with_null_values.html#_missing_query |
65 | 65 | $new_rule = [ |
66 | 66 | 'missing' => [ |
67 | - 'field' => $field, |
|
67 | + 'field' => $field, |
|
68 | 68 | ], |
69 | 69 | ]; |
70 | 70 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html |
106 | 106 | $new_rule = [ |
107 | 107 | 'exists' => [ |
108 | - 'field' => $field, |
|
108 | + 'field' => $field, |
|
109 | 109 | ], |
110 | 110 | ]; |
111 | 111 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html |
114 | 114 | $new_rule = [ |
115 | 115 | 'regexp' => [ |
116 | - $field => [ |
|
116 | + $field => [ |
|
117 | 117 | 'value' => $operand->getPattern() |
118 | 118 | // 'flags' => 'INTERSECTION|COMPLEMENT|EMPTY', |
119 | 119 | // 'max_determinized_states' => 2000 |
@@ -67,23 +67,20 @@ discard block |
||
67 | 67 | 'field' => $field, |
68 | 68 | ], |
69 | 69 | ]; |
70 | - } |
|
71 | - else { |
|
70 | + } else { |
|
72 | 71 | $new_rule = [ |
73 | 72 | 'term' => [ |
74 | 73 | $field => $operand->getValue() |
75 | 74 | ] |
76 | 75 | ]; |
77 | 76 | } |
78 | - } |
|
79 | - elseif ($operator == 'in') { |
|
77 | + } elseif ($operator == 'in') { |
|
80 | 78 | $new_rule = [ |
81 | 79 | 'terms' => [ |
82 | 80 | $field => $operand->getPossibilities() |
83 | 81 | ] |
84 | 82 | ]; |
85 | - } |
|
86 | - elseif ($operator == '<') { |
|
83 | + } elseif ($operator == '<') { |
|
87 | 84 | $new_rule = [ |
88 | 85 | 'range' => [ |
89 | 86 | $field => [ |
@@ -91,8 +88,7 @@ discard block |
||
91 | 88 | ], |
92 | 89 | ] |
93 | 90 | ]; |
94 | - } |
|
95 | - elseif ($operator == '>') { |
|
91 | + } elseif ($operator == '>') { |
|
96 | 92 | $new_rule = [ |
97 | 93 | 'range' => [ |
98 | 94 | $field => [ |
@@ -100,8 +96,7 @@ discard block |
||
100 | 96 | ], |
101 | 97 | ] |
102 | 98 | ]; |
103 | - } |
|
104 | - elseif ($operator == '<=') { |
|
99 | + } elseif ($operator == '<=') { |
|
105 | 100 | $new_rule = [ |
106 | 101 | 'range' => [ |
107 | 102 | $field => [ |
@@ -109,8 +104,7 @@ discard block |
||
109 | 104 | ], |
110 | 105 | ] |
111 | 106 | ]; |
112 | - } |
|
113 | - elseif ($operator == '>=') { |
|
107 | + } elseif ($operator == '>=') { |
|
114 | 108 | $new_rule = [ |
115 | 109 | 'range' => [ |
116 | 110 | $field => [ |
@@ -118,16 +112,14 @@ discard block |
||
118 | 112 | ], |
119 | 113 | ] |
120 | 114 | ]; |
121 | - } |
|
122 | - elseif ($operator == '!=' && $operand->getValue() === null) { |
|
115 | + } elseif ($operator == '!=' && $operand->getValue() === null) { |
|
123 | 116 | // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html |
124 | 117 | $new_rule = [ |
125 | 118 | 'exists' => [ |
126 | 119 | 'field' => $field, |
127 | 120 | ], |
128 | 121 | ]; |
129 | - } |
|
130 | - elseif ($operator == 'regexp') { |
|
122 | + } elseif ($operator == 'regexp') { |
|
131 | 123 | // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html |
132 | 124 | $new_rule = [ |
133 | 125 | 'regexp' => [ |
@@ -138,8 +130,7 @@ discard block |
||
138 | 130 | ], |
139 | 131 | ], |
140 | 132 | ]; |
141 | - } |
|
142 | - else { |
|
133 | + } else { |
|
143 | 134 | throw new \InvalidArgumentException( |
144 | 135 | "Unhandled operator '$operator' during ES query generation" |
145 | 136 | ); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @param LogicalFilter $filter |
21 | 21 | */ |
22 | - public function convert( LogicalFilter $filter ) |
|
22 | + public function convert(LogicalFilter $filter) |
|
23 | 23 | { |
24 | 24 | $this->output = [ |
25 | 25 | ]; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | protected function appendToLastOrOperandKey($rule) |
163 | 163 | { |
164 | 164 | $last_key = $this->getLastOrOperandKey(); |
165 | - $this->output[ $last_key ]['bool']['must'][] = $rule; |
|
165 | + $this->output[$last_key]['bool']['must'][] = $rule; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /**/ |
@@ -14,10 +14,10 @@ |
||
14 | 14 | |
15 | 15 | /** |
16 | 16 | */ |
17 | - public function __construct( $field, array $limits ) |
|
17 | + public function __construct($field, array $limits) |
|
18 | 18 | { |
19 | - $this->addOperand( new AboveOrEqualRule($field, $limits[0]) ); |
|
20 | - $this->addOperand( new BelowOrEqualRule($field, $limits[1]) ); |
|
19 | + $this->addOperand(new AboveOrEqualRule($field, $limits[0])); |
|
20 | + $this->addOperand(new BelowOrEqualRule($field, $limits[1])); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | /** |
31 | 31 | */ |
32 | - public function getOption($name, array $contextual_options=[]) |
|
32 | + public function getOption($name, array $contextual_options = []) |
|
33 | 33 | { |
34 | 34 | $options = $this->getOptions($contextual_options); |
35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @param $contextual_options |
41 | 41 | */ |
42 | - public function getOptions(array $contextual_options=[]) |
|
42 | + public function getOptions(array $contextual_options = []) |
|
43 | 43 | { |
44 | 44 | $default_options = LogicalFilter::getDefaultOptions(); |
45 | 45 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param string $field The field to apply the rule on. |
17 | 17 | * @param array $value The value the field can equal to. |
18 | 18 | */ |
19 | - public function __construct( $field, $value ) |
|
19 | + public function __construct($field, $value) |
|
20 | 20 | { |
21 | 21 | $this->field = $field; |
22 | 22 | $this->value = $value; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function hasSolution(array $contextual_options=[]) |
|
45 | + public function hasSolution(array $contextual_options = []) |
|
46 | 46 | { |
47 | 47 | return true; |
48 | 48 | } |