Passed
Push — master ( 19906d...c89cd1 )
by Jean
02:45
created
src/Rule/Trait_RuleWithField.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     /**
24 24
      * @return string $field
25 25
      */
26
-    final public function setField( $field )
26
+    final public function setField($field)
27 27
     {
28 28
         if (!is_scalar($field)) {
29 29
             throw new \InvalidArgumentEXception(
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
     final public function renameField($renamings)
50 50
     {
51 51
         if (is_callable($renamings)) {
52
-            $this->setField( call_user_func($renamings, $this->field) );
52
+            $this->setField(call_user_func($renamings, $this->field));
53 53
         }
54 54
         elseif (is_array($renamings)) {
55 55
             if (isset($renamings[$this->field]))
56
-                $this->setField( $renamings[$this->field] );
56
+                $this->setField($renamings[$this->field]);
57 57
         }
58 58
         else {
59 59
             throw new \InvalidArgumentException(
60 60
                 "\$renamings MUST be a callable or an associative array "
61
-                ."instead of: " . var_export($renamings, true)
61
+                ."instead of: ".var_export($renamings, true)
62 62
             );
63 63
         }
64 64
 
Please login to merge, or discard this patch.
src/Rule/AbstractOperationRule.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     const remove_negations        = 'remove_negations';
21 21
     const rootify_disjunctions    = 'rootify_disjunctions';
22 22
     const unify_atomic_operands   = 'unify_atomic_operands';
23
-    const remove_invalid_branches = 'remove_invalid_branches';    // simplified after this step
23
+    const remove_invalid_branches = 'remove_invalid_branches'; // simplified after this step
24 24
 
25 25
     const simplified              = self::remove_invalid_branches;
26 26
 
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 
44 44
     /**
45 45
      */
46
-    public function __construct( array $operands=[] )
46
+    public function __construct(array $operands = [])
47 47
     {
48
-        $this->setOperands( $operands );
48
+        $this->setOperands($operands);
49 49
         $this->flushCache();
50 50
     }
51 51
 
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @return $this
66 66
      */
67
-    public function addOperand( AbstractRule $new_operand )
67
+    public function addOperand(AbstractRule $new_operand)
68 68
     {
69
-        if (!isset($this->operands[ $id = $new_operand->getSemanticId() ])) {
70
-            $this->operands[ $id ] = $new_operand;
69
+        if (!isset($this->operands[$id = $new_operand->getSemanticId()])) {
70
+            $this->operands[$id] = $new_operand;
71 71
 
72 72
             if ($this->current_simplification_step)
73 73
                 $this->current_simplification_step = null;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function getOperands()
85 85
     {
86
-        return array_values( $this->operands );
86
+        return array_values($this->operands);
87 87
     }
88 88
 
89 89
     /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     /**
124 124
      * @param string $step_to_go_to
125 125
      */
126
-    public function moveSimplificationStepForward($step_to_go_to, array $simplification_options, $force=false)
126
+    public function moveSimplificationStepForward($step_to_go_to, array $simplification_options, $force = false)
127 127
     {
128 128
         if (!in_array($step_to_go_to, self::simplification_steps)) {
129 129
             throw new \InvalidArgumentException(
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
         if (!$force && $this->current_simplification_step != null) {
136 136
             $steps_indices = array_flip(self::simplification_steps);
137 137
 
138
-            $current_index = $steps_indices[ $this->current_simplification_step ];
139
-            $target_index  = $steps_indices[ $step_to_go_to ];
138
+            $current_index = $steps_indices[$this->current_simplification_step];
139
+            $target_index  = $steps_indices[$step_to_go_to];
140 140
 
141
-            if ( $current_index >= $target_index ) {
141
+            if ($current_index >= $target_index) {
142 142
                 // allow recall of previous step without going back
143 143
                 return;
144 144
             }
145
-            elseif ( $current_index < $target_index - 1 ) {
145
+            elseif ($current_index < $target_index - 1) {
146 146
                 throw new \LogicException(
147
-                    "$step_to_go_to MUST be fullfilled after " . self::simplification_steps[$target_index - 1]
148
-                    . " instead of the current step: " . $this->current_simplification_step
149
-                    ."\nfor: " . $this
147
+                    "$step_to_go_to MUST be fullfilled after ".self::simplification_steps[$target_index - 1]
148
+                    . " instead of the current step: ".$this->current_simplification_step
149
+                    ."\nfor: ".$this
150 150
                 );
151 151
             }
152 152
         }
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 
175 175
         $steps_indices = array_flip(self::simplification_steps);
176 176
 
177
-        $current_index = $steps_indices[ $this->current_simplification_step ];
178
-        $step_index    = $steps_indices[ $step ];
177
+        $current_index = $steps_indices[$this->current_simplification_step];
178
+        $step_index    = $steps_indices[$step];
179 179
 
180 180
         return $current_index >= $step_index;
181 181
     }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
                 }
203 203
 
204 204
                 if ($operands[$i] instanceof AbstractOperationRule) {
205
-                    $operands[$i]->removeNegations( $contextual_options );
205
+                    $operands[$i]->removeNegations($contextual_options);
206 206
                 }
207 207
             }
208 208
 
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
      *
223 223
      * @return $this;
224 224
      */
225
-    public function cleanOperations($simplification_options, $recurse=true)
225
+    public function cleanOperations($simplification_options, $recurse = true)
226 226
     {
227 227
         if ($recurse) foreach ($this->operands as $i => $operand) {
228
-            if (    $operand instanceof AbstractOperationRule
228
+            if ($operand instanceof AbstractOperationRule
229 229
                 && !$operand instanceof InRule
230 230
                 && !$operand instanceof NotEqualRule
231 231
                 && !$operand instanceof NotInRule
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     public function unifyAtomicOperands($simplification_strategy_step = false, array $contextual_options)
295 295
     {
296 296
         if ($simplification_strategy_step)
297
-            $this->moveSimplificationStepForward( self::unify_atomic_operands, $contextual_options );
297
+            $this->moveSimplificationStepForward(self::unify_atomic_operands, $contextual_options);
298 298
 
299 299
         // $this->dump(true);
300 300
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                 catch (\Exception $e) {
329 329
                     VisibilityViolator::setHiddenProperty(
330 330
                         $e, 'message',
331
-                        $e->getMessage() . "\n" . var_export($operandsByOperator, true)
331
+                        $e->getMessage()."\n".var_export($operandsByOperator, true)
332 332
                     );
333 333
 
334 334
                     throw $e;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             }
337 337
         }
338 338
 
339
-        return $this->setOperandsOrReplaceByOperation( $unifiedOperands, $contextual_options );
339
+        return $this->setOperandsOrReplaceByOperation($unifiedOperands, $contextual_options);
340 340
     }
341 341
 
342 342
     private static $simplification_cache = [];
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
      *
353 353
      * @return AbstractRule the simplified rule
354 354
      */
355
-    final public function simplify($options=[])
355
+    final public function simplify($options = [])
356 356
     {
357
-        $step_to_stop_before = !empty($options['stop_before'])        ? $options['stop_before'] : null;
358
-        $step_to_stop_after  = !empty($options['stop_after'])         ? $options['stop_after']  : null;
357
+        $step_to_stop_before = !empty($options['stop_before']) ? $options['stop_before'] : null;
358
+        $step_to_stop_after  = !empty($options['stop_after']) ? $options['stop_after'] : null;
359 359
         $force_logical_core  = !empty($options['force_logical_core']) ? $options['force_logical_core'] : false;
360 360
 
361 361
         if ($step_to_stop_before && !in_array($step_to_stop_before, self::simplification_steps)) {
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 
391 391
         // $instance->dump(true);
392 392
 
393
-        if ($step_to_stop_after  == self::remove_negations ||
394
-            $step_to_stop_before == self::rootify_disjunctions )
393
+        if ($step_to_stop_after == self::remove_negations ||
394
+            $step_to_stop_before == self::rootify_disjunctions)
395 395
             return $instance;
396 396
 
397 397
         // $instance->dump(true);
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 
404 404
         // $instance->dump(true);
405 405
 
406
-        if ($step_to_stop_after  == self::rootify_disjunctions ||
407
-            $step_to_stop_before == self::unify_atomic_operands )
406
+        if ($step_to_stop_after == self::rootify_disjunctions ||
407
+            $step_to_stop_before == self::unify_atomic_operands)
408 408
             return $instance;
409 409
 
410 410
         if (!$instance instanceof AbstractAtomicRule) {
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 
415 415
             // $instance->dump(true);
416 416
 
417
-            if ($step_to_stop_after  == self::unify_atomic_operands ||
418
-                $step_to_stop_before == self::remove_invalid_branches )
417
+            if ($step_to_stop_after == self::unify_atomic_operands ||
418
+                $step_to_stop_before == self::remove_invalid_branches)
419 419
                 return $instance;
420 420
 
421 421
             $instance->cleanOperations($options);
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
         // last non recursive clean
432 432
         // TODO kind of monad|become|cese
433 433
         //@see https://github.com/jclaveau/php-logical-filter/issues/20
434
-        if ($instance instanceof AndRule || $instance instanceof OrRule ) {
434
+        if ($instance instanceof AndRule || $instance instanceof OrRule) {
435 435
 
436 436
             if (!$instance->getOperands())
437 437
                 return $instance;
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 
471 471
         $cache_keys[] = $instance->getSemanticId().'-'.$options_id;
472 472
         foreach ($cache_keys as $cache_key) {
473
-            self::$simplification_cache[ $cache_key ] = $instance;
473
+            self::$simplification_cache[$cache_key] = $instance;
474 474
         }
475 475
 
476 476
         return $instance->copy();
@@ -493,13 +493,13 @@  discard block
 block discarded – undo
493 493
             // For FilteredValue and FilteredKey
494 494
             $field = (string) $field;
495 495
 
496
-            if (!isset($operandsByFields[ $field ]))
497
-                $operandsByFields[ $field ] = [];
496
+            if (!isset($operandsByFields[$field]))
497
+                $operandsByFields[$field] = [];
498 498
 
499
-            if (!isset($operandsByFields[ $field ][ $operand::operator ]))
500
-                $operandsByFields[ $field ][ $operand::operator ] = [];
499
+            if (!isset($operandsByFields[$field][$operand::operator]))
500
+                $operandsByFields[$field][$operand::operator] = [];
501 501
 
502
-            $operandsByFields[ $field ][ $operand::operator ][] = $operand;
502
+            $operandsByFields[$field][$operand::operator][] = $operand;
503 503
         }
504 504
 
505 505
         return $operandsByFields;
@@ -522,13 +522,13 @@  discard block
 block discarded – undo
522 522
             // For FilteredValue and FilteredKey
523 523
             $field = (string) $field;
524 524
 
525
-            if (!isset($operandsByFields[ $field ]))
526
-                $operandsByFields[ $field ] = [];
525
+            if (!isset($operandsByFields[$field]))
526
+                $operandsByFields[$field] = [];
527 527
 
528
-            if (!isset($operandsByFields[ $field ][ $operand::operator ]))
529
-                $operandsByFields[ $field ][ $operand::operator ] = [];
528
+            if (!isset($operandsByFields[$field][$operand::operator]))
529
+                $operandsByFields[$field][$operand::operator] = [];
530 530
 
531
-            $operandsByFields[ $field ][ $operand::operator ][] = $operand;
531
+            $operandsByFields[$field][$operand::operator][] = $operand;
532 532
         }
533 533
 
534 534
         return $operandsByFields;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
      *
567 567
      * @return AbstractRule|null The operand if it exists or null
568 568
      */
569
-    protected function getOperandAt($index=0)
569
+    protected function getOperandAt($index = 0)
570 570
     {
571 571
         $operands = array_values($this->operands);
572 572
         if (isset($operands[$index]))
Please login to merge, or discard this patch.
src/Rule/AbstractRule.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public static function findSymbolicOperator($english_operator)
35 35
     {
36
-        $association = array_flip( self::$ruleAliases );
37
-        if (isset($association[ $english_operator ]))
38
-            return $association[ $english_operator ];
36
+        $association = array_flip(self::$ruleAliases);
37
+        if (isset($association[$english_operator]))
38
+            return $association[$english_operator];
39 39
 
40 40
         return $english_operator;
41 41
     }
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
     public static function findEnglishOperator($symbolic_operator)
46 46
     {
47 47
         $association = self::$ruleAliases;
48
-        if (isset($association[ $symbolic_operator ]))
49
-            return $association[ $symbolic_operator ];
48
+        if (isset($association[$symbolic_operator]))
49
+            return $association[$symbolic_operator];
50 50
 
51 51
         return $symbolic_operator;
52 52
     }
@@ -63,15 +63,15 @@  discard block
 block discarded – undo
63 63
      *
64 64
      * @return $this
65 65
      */
66
-    public static function generateSimpleRule($field, $type, $values, array $options=[])
66
+    public static function generateSimpleRule($field, $type, $values, array $options = [])
67 67
     {
68
-        $cache_key = hash('md4', serialize( func_get_args()) );
68
+        $cache_key = hash('md4', serialize(func_get_args()));
69 69
         if (isset(self::$static_cache['rules_generation'][$cache_key]))
70 70
             return self::$static_cache['rules_generation'][$cache_key]->copy();
71 71
 
72 72
         $ruleClass = self::getRuleClass($type);
73 73
 
74
-        return self::$static_cache['rules_generation'][$cache_key] = new $ruleClass( $field, $values, $options );
74
+        return self::$static_cache['rules_generation'][$cache_key] = new $ruleClass($field, $values, $options);
75 75
     }
76 76
 
77 77
     /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             . str_replace('_', '', ucwords($english_rule_operator, '_'))
89 89
             . 'Rule';
90 90
 
91
-        if (!class_exists( $rule_class)) {
91
+        if (!class_exists($rule_class)) {
92 92
             throw new \InvalidArgumentException(
93 93
                 "The class '$rule_class' corresponding to the  operator "
94 94
                 ."'$rule_operator' / '$english_rule_operator' cannot be found."
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      *
118 118
      * @return $this
119 119
      */
120
-    final public function dump($exit=false, array $options=[])
120
+    final public function dump($exit = false, array $options = [])
121 121
     {
122 122
         $default_options = [
123 123
             'callstack_depth' => 2,
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
             // 'show_instance'   => false,
126 126
         ];
127 127
         foreach ($default_options as $default_option => &$default_value) {
128
-            if (!isset($options[ $default_option ]))
129
-                $options[ $default_option ] = $default_value;
128
+            if (!isset($options[$default_option]))
129
+                $options[$default_option] = $default_value;
130 130
         }
131 131
         extract($options);
132 132
 
133 133
         $bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $callstack_depth);
134
-        $caller = $bt[ $callstack_depth - 2 ];
134
+        $caller = $bt[$callstack_depth - 2];
135 135
 
136
-        echo "\n" . $caller['file'] . ':' . $caller['line'] . "\n";
136
+        echo "\n".$caller['file'].':'.$caller['line']."\n";
137 137
         if ($mode == 'string') {
138
-            if ( ! isset($options['indent_unit']))
138
+            if (!isset($options['indent_unit']))
139 139
                 $options['indent_unit'] = "    ";
140 140
 
141 141
             echo ($this->toString($options));
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
                 ini_set('xdebug.overload_var_dump', 1);
151 151
         }
152 152
         elseif ($mode == 'xdebug') {
153
-            if ( ! function_exists('xdebug_is_enabled')) {
153
+            if (!function_exists('xdebug_is_enabled')) {
154 154
                 throw new \RuntimeException("Xdebug is not installed");
155 155
             }
156
-            if ( ! xdebug_is_enabled()) {
156
+            if (!xdebug_is_enabled()) {
157 157
                 throw new \RuntimeException("Xdebug is disabled");
158 158
             }
159 159
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         else {
172 172
             throw new \InvalidArgumentException(
173 173
                  "'mode' option must belong to ['string', 'export', 'dump'] "
174
-                ."instead of " . var_export($mode, true)
174
+                ."instead of ".var_export($mode, true)
175 175
             );
176 176
         }
177 177
         echo "\n\n";
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
             return $this->cache['semantic_id'];
251 251
 
252 252
         // return hash('crc32b', serialize( $this->toArray() ));
253
-        return hash('md4', serialize( $this->toArray(['semantic' => true]) ))  // faster but longer
253
+        return hash('md4', serialize($this->toArray(['semantic' => true])))  // faster but longer
254 254
               .'-'
255
-              .hash('md4', serialize( $this->options ))
255
+              .hash('md4', serialize($this->options))
256 256
               ;
257 257
     }
258 258
 
Please login to merge, or discard this patch.
Braces   +46 added lines, -40 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@  discard block
 block discarded – undo
34 34
     public static function findSymbolicOperator($english_operator)
35 35
     {
36 36
         $association = array_flip( self::$ruleAliases );
37
-        if (isset($association[ $english_operator ]))
38
-            return $association[ $english_operator ];
37
+        if (isset($association[ $english_operator ])) {
38
+                    return $association[ $english_operator ];
39
+        }
39 40
 
40 41
         return $english_operator;
41 42
     }
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
     public static function findEnglishOperator($symbolic_operator)
46 47
     {
47 48
         $association = self::$ruleAliases;
48
-        if (isset($association[ $symbolic_operator ]))
49
-            return $association[ $symbolic_operator ];
49
+        if (isset($association[ $symbolic_operator ])) {
50
+                    return $association[ $symbolic_operator ];
51
+        }
50 52
 
51 53
         return $symbolic_operator;
52 54
     }
@@ -66,8 +68,9 @@  discard block
 block discarded – undo
66 68
     public static function generateSimpleRule($field, $type, $values, array $options=[])
67 69
     {
68 70
         $cache_key = hash('md4', serialize( func_get_args()) );
69
-        if (isset(self::$static_cache['rules_generation'][$cache_key]))
70
-            return self::$static_cache['rules_generation'][$cache_key]->copy();
71
+        if (isset(self::$static_cache['rules_generation'][$cache_key])) {
72
+                    return self::$static_cache['rules_generation'][$cache_key]->copy();
73
+        }
71 74
 
72 75
         $ruleClass = self::getRuleClass($type);
73 76
 
@@ -125,8 +128,9 @@  discard block
 block discarded – undo
125 128
             // 'show_instance'   => false,
126 129
         ];
127 130
         foreach ($default_options as $default_option => &$default_value) {
128
-            if (!isset($options[ $default_option ]))
129
-                $options[ $default_option ] = $default_value;
131
+            if (!isset($options[ $default_option ])) {
132
+                            $options[ $default_option ] = $default_value;
133
+            }
130 134
         }
131 135
         extract($options);
132 136
 
@@ -135,21 +139,22 @@  discard block
 block discarded – undo
135 139
 
136 140
         echo "\n" . $caller['file'] . ':' . $caller['line'] . "\n";
137 141
         if ($mode == 'string') {
138
-            if ( ! isset($options['indent_unit']))
139
-                $options['indent_unit'] = "    ";
142
+            if ( ! isset($options['indent_unit'])) {
143
+                            $options['indent_unit'] = "    ";
144
+            }
140 145
 
141 146
             echo ($this->toString($options));
142
-        }
143
-        elseif ($mode == 'dump') {
144
-            if ($xdebug_enabled = ini_get('xdebug.overload_var_dump'))
145
-                ini_set('xdebug.overload_var_dump', 0);
147
+        } elseif ($mode == 'dump') {
148
+            if ($xdebug_enabled = ini_get('xdebug.overload_var_dump')) {
149
+                            ini_set('xdebug.overload_var_dump', 0);
150
+            }
146 151
 
147 152
             var_dump($this->toArray($options));
148 153
 
149
-            if ($xdebug_enabled)
150
-                ini_set('xdebug.overload_var_dump', 1);
151
-        }
152
-        elseif ($mode == 'xdebug') {
154
+            if ($xdebug_enabled) {
155
+                            ini_set('xdebug.overload_var_dump', 1);
156
+            }
157
+        } elseif ($mode == 'xdebug') {
153 158
             if ( ! function_exists('xdebug_is_enabled')) {
154 159
                 throw new \RuntimeException("Xdebug is not installed");
155 160
             }
@@ -157,18 +162,18 @@  discard block
 block discarded – undo
157 162
                 throw new \RuntimeException("Xdebug is disabled");
158 163
             }
159 164
 
160
-            if ($xdebug_enabled = ini_get('xdebug.overload_var_dump'))
161
-                ini_set('xdebug.overload_var_dump', 1);
165
+            if ($xdebug_enabled = ini_get('xdebug.overload_var_dump')) {
166
+                            ini_set('xdebug.overload_var_dump', 1);
167
+            }
162 168
 
163 169
             var_dump($this->toArray($options));
164 170
 
165
-            if ($xdebug_enabled)
166
-                ini_set('xdebug.overload_var_dump', 0);
167
-        }
168
-        elseif ($mode == 'export') {
171
+            if ($xdebug_enabled) {
172
+                            ini_set('xdebug.overload_var_dump', 0);
173
+            }
174
+        } elseif ($mode == 'export') {
169 175
             var_export($this->toArray($options));
170
-        }
171
-        else {
176
+        } else {
172 177
             throw new \InvalidArgumentException(
173 178
                  "'mode' option must belong to ['string', 'export', 'dump'] "
174 179
                 ."instead of " . var_export($mode, true)
@@ -176,8 +181,9 @@  discard block
 block discarded – undo
176 181
         }
177 182
         echo "\n\n";
178 183
 
179
-        if ($exit)
180
-            exit;
184
+        if ($exit) {
185
+                    exit;
186
+        }
181 187
 
182 188
         return $this;
183 189
     }
@@ -233,8 +239,9 @@  discard block
 block discarded – undo
233 239
      */
234 240
     public function getInstanceId()
235 241
     {
236
-        if ($this->instance_id)
237
-            return $this->instance_id;
242
+        if ($this->instance_id) {
243
+                    return $this->instance_id;
244
+        }
238 245
 
239 246
         return $this->instance_id = get_class($this).':'.spl_object_id($this);
240 247
     }
@@ -246,8 +253,9 @@  discard block
 block discarded – undo
246 253
      */
247 254
     final public function getSemanticId()
248 255
     {
249
-        if (isset($this->cache['semantic_id']))
250
-            return $this->cache['semantic_id'];
256
+        if (isset($this->cache['semantic_id'])) {
257
+                    return $this->cache['semantic_id'];
258
+        }
251 259
 
252 260
         // return hash('crc32b', serialize( $this->toArray() ));
253 261
         return hash('md4', serialize( $this->toArray(['semantic' => true]) ))  // faster but longer
@@ -276,20 +284,18 @@  discard block
 block discarded – undo
276 284
                     $this
277 285
                 ])
278 286
             ]);
279
-        }
280
-        elseif ($this instanceof AndRule) {
287
+        } elseif ($this instanceof AndRule) {
281 288
             $ruleTree = new OrRule([
282 289
                 $this
283 290
             ]);
284
-        }
285
-        elseif ($this instanceof OrRule) {
291
+        } elseif ($this instanceof OrRule) {
286 292
             foreach ($this->operands as $i => $operand) {
287
-                if (!$operand instanceof AndRule)
288
-                    $this->operands[$i] = new AndRule([$operand]);
293
+                if (!$operand instanceof AndRule) {
294
+                                    $this->operands[$i] = new AndRule([$operand]);
295
+                }
289 296
             }
290 297
             $ruleTree = $this;
291
-        }
292
-        else {
298
+        } else {
293 299
             throw new \LogicException(
294 300
                 "Unhandled type of simplified rules provided for conversion: "
295 301
                 .$this
Please login to merge, or discard this patch.