Completed
Push — master ( 175b46...11f7d6 )
by Jean
03:37
created
src/Filterer/Filterer.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function onRowMatches(&$row, $key, &$rows, $matching_case, $options)
49 49
     {
50
-        if (isset($options[ self::on_row_matches ])) {
51
-            $callback = $options[ self::on_row_matches ];
50
+        if (isset($options[self::on_row_matches])) {
51
+            $callback = $options[self::on_row_matches];
52 52
         }
53
-        elseif (isset($this->custom_actions[ self::on_row_matches ])) {
54
-            $callback = $this->custom_actions[ self::on_row_matches ];
53
+        elseif (isset($this->custom_actions[self::on_row_matches])) {
54
+            $callback = $this->custom_actions[self::on_row_matches];
55 55
         }
56 56
         else {
57 57
             return;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function onRowMismatches(&$row, $key, &$rows, $matching_case, $options)
75 75
     {
76
-        if (   ! $this->custom_actions
76
+        if ( ! $this->custom_actions
77 77
             && ! isset($options[self::on_row_mismatches])
78 78
             && ! isset($options[self::on_row_matches])
79 79
         ) {
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
             return;
83 83
         }
84 84
 
85
-        if (isset($options[ self::on_row_mismatches ])) {
86
-            $callback = $options[ self::on_row_mismatches ];
85
+        if (isset($options[self::on_row_mismatches])) {
86
+            $callback = $options[self::on_row_mismatches];
87 87
         }
88
-        elseif (isset($this->custom_actions[ self::on_row_mismatches ])) {
89
-            $callback = $this->custom_actions[ self::on_row_mismatches ];
88
+        elseif (isset($this->custom_actions[self::on_row_mismatches])) {
89
+            $callback = $this->custom_actions[self::on_row_mismatches];
90 90
         }
91 91
         else {
92 92
             return;
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
      * @param Iterable        $tree_to_filter
124 124
      * @param array           $options
125 125
      */
126
-    public function apply( LogicalFilter $filter, $tree_to_filter, $options=[] )
126
+    public function apply(LogicalFilter $filter, $tree_to_filter, $options = [])
127 127
     {
128
-        if (! $filter->hasSolution()) {
128
+        if ( ! $filter->hasSolution()) {
129 129
             return null;
130 130
         }
131 131
 
132
-        if (! isset($options['recurse'])) {
132
+        if ( ! isset($options['recurse'])) {
133 133
             $options['recurse'] = 'before';
134 134
         }
135
-        elseif (! in_array($options['recurse'], ['before', 'after', null])) {
135
+        elseif ( ! in_array($options['recurse'], ['before', 'after', null])) {
136 136
             throw new \InvalidArgumentException(
137 137
                 "Invalid value for 'recurse' option: "
138 138
                 .var_export($options['recurse'], true)
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
         }
142 142
 
143 143
         return $this->foreachRow(
144
-            !$filter->getRules() ? [] : $filter->addMinimalCase()->getRules()->getOperands(),
144
+            ! $filter->getRules() ? [] : $filter->addMinimalCase()->getRules()->getOperands(),
145 145
             $tree_to_filter,
146
-            $path=[],
146
+            $path = [],
147 147
             $options
148 148
         );
149 149
     }
150 150
 
151 151
     /**
152 152
      */
153
-    protected function foreachRow(array $root_cases, $tree_to_filter, array $path, $options=[])
153
+    protected function foreachRow(array $root_cases, $tree_to_filter, array $path, $options = [])
154 154
     {
155 155
         // Once the rules are prepared, we parse the data
156 156
         foreach ($tree_to_filter as $row_index => $row_to_filter) {
@@ -209,33 +209,33 @@  discard block
 block discarded – undo
209 209
      *
210 210
      * @return bool
211 211
      */
212
-    public function hasMatchingCase( LogicalFilter $filter, $row_to_check, $key_to_check, $options=[] )
212
+    public function hasMatchingCase(LogicalFilter $filter, $row_to_check, $key_to_check, $options = [])
213 213
     {
214
-        if (! $filter->hasSolution()) {
214
+        if ( ! $filter->hasSolution()) {
215 215
             return null;
216 216
         }
217 217
 
218 218
         return $this->applyOnRow(
219
-            !$filter->getRules() ? [] : $filter->addMinimalCase()->getRules()->getOperands(),
219
+            ! $filter->getRules() ? [] : $filter->addMinimalCase()->getRules()->getOperands(),
220 220
             $row_to_check,
221
-            $path=[$key_to_check],
221
+            $path = [$key_to_check],
222 222
             $options
223 223
         );
224 224
     }
225 225
 
226 226
     /**
227 227
      */
228
-    protected function applyOnRow(array $root_cases, $row_to_filter, array $path, $options=[])
228
+    protected function applyOnRow(array $root_cases, $row_to_filter, array $path, $options = [])
229 229
     {
230 230
         $operands_validation_row_cache = [];
231 231
 
232
-        if (! $root_cases) {
232
+        if ( ! $root_cases) {
233 233
             $matching_case = true;
234 234
         }
235 235
         else {
236 236
             $matching_case = null;
237 237
             foreach ($root_cases as $and_case_index => $and_case) {
238
-                if (! empty($options['debug'])) {
238
+                if ( ! empty($options['debug'])) {
239 239
                     var_dump("Case $and_case_index: ".$and_case);
240 240
                 }
241 241
 
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 
262 262
                     $cache_key = $and_case_index.'~|~'.$field.'~|~'.$operator;
263 263
 
264
-                    if (! empty($operands_validation_row_cache[ $cache_key ])) {
265
-                        $is_valid = $operands_validation_row_cache[ $cache_key ];
264
+                    if ( ! empty($operands_validation_row_cache[$cache_key])) {
265
+                        $is_valid = $operands_validation_row_cache[$cache_key];
266 266
                     }
267 267
                     else {
268 268
                         $is_valid = $this->validateRule(
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                             $options
276 276
                         );
277 277
 
278
-                        $operands_validation_row_cache[ $cache_key ] = $is_valid;
278
+                        $operands_validation_row_cache[$cache_key] = $is_valid;
279 279
                     }
280 280
 
281 281
                     if (false === $is_valid) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@
 block discarded – undo
236 236
             $matching_case = null;
237 237
             foreach ($root_cases as $and_case_index => $and_case) {
238 238
                 if (! empty($options['debug'])) {
239
-                    var_dump("Case $and_case_index: ".$and_case);
239
+                    var_dump("case $and_case_index: ".$and_case);
240 240
                 }
241 241
 
242 242
                 $case_is_good = null;
Please login to merge, or discard this patch.