Passed
Push — master ( 6d8c8f...ee4ff9 )
by Jean
03:10
created
src/Rule/NotRule.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 
13 13
     /**
14 14
      */
15
-    public function __construct( AbstractRule $operand=null, array $options=[] )
15
+    public function __construct(AbstractRule $operand = null, array $options = [])
16 16
     {
17
-        if ( ! empty($options)) {
17
+        if (!empty($options)) {
18 18
             $this->setOptions($options);
19 19
         }
20 20
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     /**
29 29
      */
30
-    public function isNormalizationAllowed(array $current_simplification_options=[])
30
+    public function isNormalizationAllowed(array $current_simplification_options = [])
31 31
     {
32 32
         $operand = $this->getOperandAt(0);
33 33
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function negateOperand(array $current_simplification_options)
48 48
     {
49
-        if ( ! $this->isNormalizationAllowed($current_simplification_options)) {
49
+        if (!$this->isNormalizationAllowed($current_simplification_options)) {
50 50
             return $this;
51 51
         }
52 52
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
                     ]);
81 81
                 }
82 82
                 else {
83
-                    $new_rule = new NotEqualRule( $field, $operand->getValue() );
83
+                    $new_rule = new NotEqualRule($field, $operand->getValue());
84 84
                 }
85 85
             }
86 86
             elseif ($operand instanceof NotEqualRule) {
87
-                $new_rule = new EqualRule( $field, $operand->getValue() );
87
+                $new_rule = new EqualRule($field, $operand->getValue());
88 88
             }
89 89
         }
90 90
 
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 
120 120
                 $tmp = [];
121 121
                 foreach ($current_operand_possibilities->getOperands() as $current_operand_possibility) {
122
-                    $tmp[] = $current_operand_possibility->addOperand( $next_operand->copy() );
122
+                    $tmp[] = $current_operand_possibility->addOperand($next_operand->copy());
123 123
                 }
124 124
                 $current_operand_possibilities->setOperands($tmp);
125 125
 
126 126
                 foreach ($next_operand_possibilities->getOperands() as $next_operand_possibility) {
127 127
                     $current_operand_possibilities->addOperand(
128
-                        $next_operand_possibility->addOperand( new NotRule($next_operand->copy()) )
128
+                        $next_operand_possibility->addOperand(new NotRule($next_operand->copy()))
129 129
                     );
130 130
                 }
131 131
             }
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
             // We remove the only possibility where no rule is negated
134 134
             $combinations = $current_operand_possibilities->getOperands();
135 135
             array_shift($combinations); // The first rule contains no negation
136
-            $new_rule->setOperands( $combinations )
136
+            $new_rule->setOperands($combinations)
137 137
                 // ->dump(true)
138 138
                 ;
139 139
         }
140 140
         elseif ($operand instanceof OrRule) {
141 141
 
142 142
             // $operand->dump(true);
143
-            if (     $operand instanceof InRule
144
-                && ! $operand->isNormalizationAllowed($current_simplification_options)
143
+            if ($operand instanceof InRule
144
+                && !$operand->isNormalizationAllowed($current_simplification_options)
145 145
             ) {
146 146
                 // ['not', ['field', 'in', [2, 3]]] <=> ['field', '!in', [2, 3]]
147 147
                 $new_rule = new NotInRule(
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                         [$sub_operand->copy()],
160 160
                         $current_simplification_options
161 161
                     );
162
-                    $new_rule->addOperand( $negation );
162
+                    $new_rule->addOperand($negation);
163 163
                 }
164 164
             }
165 165
             // $new_rule->dump(!true);
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
             $new_rule = $operand->getOperandAt(0);
170 170
         }
171 171
 
172
-        if ( ! isset($new_rule)) {
172
+        if (!isset($new_rule)) {
173 173
             throw new \LogicException(
174
-                'Removing NotRule(' . var_export($operand, true) . ') '
174
+                'Removing NotRule('.var_export($operand, true).') '
175 175
                 . ' not implemented'
176 176
             );
177 177
         }
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function rootifyDisjunctions($simplification_options)
190 190
     {
191
-        if ( ! $this->isNormalizationAllowed($simplification_options)) {
191
+        if (!$this->isNormalizationAllowed($simplification_options)) {
192 192
             return $this;
193 193
         }
194 194
 
195
-        $this->moveSimplificationStepForward( self::rootify_disjunctions, $simplification_options );
195
+        $this->moveSimplificationStepForward(self::rootify_disjunctions, $simplification_options);
196 196
 
197 197
         // not implemented
198 198
 
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
      */
207 207
     public function unifyAtomicOperands($simplification_strategy_step = false, array $contextual_options)
208 208
     {
209
-        if ( ! $this->isNormalizationAllowed($contextual_options)) {
209
+        if (!$this->isNormalizationAllowed($contextual_options)) {
210 210
             return $this;
211 211
         }
212 212
 
213 213
         if ($simplification_strategy_step) {
214
-            $this->moveSimplificationStepForward( self::unify_atomic_operands, $contextual_options );
214
+            $this->moveSimplificationStepForward(self::unify_atomic_operands, $contextual_options);
215 215
         }
216 216
 
217 217
         return $this;
@@ -222,19 +222,19 @@  discard block
 block discarded – undo
222 222
      *
223 223
      * @return array
224 224
      */
225
-    public function toArray(array $options=[])
225
+    public function toArray(array $options = [])
226 226
     {
227 227
         $default_options = [
228 228
             'show_instance' => false,
229 229
             'semantic'      => false,
230 230
         ];
231 231
         foreach ($default_options as $default_option => &$default_value) {
232
-            if ( ! isset($options[ $default_option ])) {
233
-                $options[ $default_option ] = $default_value;
232
+            if (!isset($options[$default_option])) {
233
+                $options[$default_option] = $default_value;
234 234
             }
235 235
         }
236 236
 
237
-        if ( ! $options['show_instance'] && isset($this->cache['array'])) {
237
+        if (!$options['show_instance'] && isset($this->cache['array'])) {
238 238
             return $this->cache['array'];
239 239
         }
240 240
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         ];
245 245
 
246 246
         // TODO make a dedicated cache entry for semantic array?
247
-        if ( ! $options['show_instance'] && ! $options['semantic']) {
247
+        if (!$options['show_instance'] && !$options['semantic']) {
248 248
             return $this->cache['array'] = $array;
249 249
         }
250 250
         else {
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
 
255 255
     /**
256 256
      */
257
-    public function toString(array $options=[])
257
+    public function toString(array $options = [])
258 258
     {
259 259
         $operator = self::operator;
260
-        if ( ! $this->operands) {
260
+        if (!$this->operands) {
261 261
             return "['{$operator}']";
262 262
         }
263 263
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
         $out = "['{$operator}',"
268 268
             . $line_break
269
-            . ($indent_unit ? : ' ')
269
+            . ($indent_unit ?: ' ')
270 270
             . str_replace($line_break, $line_break.$indent_unit, $this->getOperandAt(0)->toString($options))
271 271
             . ','
272 272
             . $line_break
@@ -304,21 +304,21 @@  discard block
 block discarded – undo
304 304
 
305 305
         if ($new_operand instanceof NotRule) {
306 306
             $operands = $new_operand->getOperands();
307
-            return reset( $operands );
307
+            return reset($operands);
308 308
         }
309
-        elseif ($new_operand instanceof EqualRule && ! $this->getOption('not_equal.normalization', $contextual_options)) {
310
-            return new NotEqualRule( $new_operand->getField(), $new_operand->getValue(), $this->options );
309
+        elseif ($new_operand instanceof EqualRule && !$this->getOption('not_equal.normalization', $contextual_options)) {
310
+            return new NotEqualRule($new_operand->getField(), $new_operand->getValue(), $this->options);
311 311
         }
312
-        elseif ($new_operand instanceof InRule && ! $this->getOption('not_in.normalization', $contextual_options)) {
313
-            return new NotInRule( $new_operand->getField(), $new_operand->getPossibilities(), $this->options );
312
+        elseif ($new_operand instanceof InRule && !$this->getOption('not_in.normalization', $contextual_options)) {
313
+            return new NotInRule($new_operand->getField(), $new_operand->getPossibilities(), $this->options);
314 314
         }
315 315
 
316 316
         try {
317 317
             // Don't use addOperand here to allow inheritance for optimizations (e.g. NotInRule)
318
-            $out = $this->setOperands( $new_operands );
318
+            $out = $this->setOperands($new_operands);
319 319
         }
320 320
         catch (\LogicException $e) {
321
-            $out = new NotRule( $new_operand );
321
+            $out = new NotRule($new_operand);
322 322
         }
323 323
 
324 324
         // $out->dump();
@@ -329,11 +329,11 @@  discard block
 block discarded – undo
329 329
     /**
330 330
      *
331 331
      */
332
-    public function hasSolution(array $contextual_options=[])
332
+    public function hasSolution(array $contextual_options = [])
333 333
     {
334 334
         $operand = $this->getOperandAt(0);
335 335
 
336
-        return $operand instanceof AbstractAtomicRule ? ! $operand->hasSolution($contextual_options) : true;
336
+        return $operand instanceof AbstractAtomicRule ? !$operand->hasSolution($contextual_options) : true;
337 337
     }
338 338
 
339 339
     /**/
Please login to merge, or discard this patch.