Passed
Push — 4.9 ( 779bac...9a64ac )
by Mikhail
02:27
created
app/Diff.php 3 patches
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
       $sequence2 = $string2;
44 44
       $end1 = strlen($string1) - 1;
45 45
       $end2 = strlen($string2) - 1;
46
-    }else{
46
+    } else{
47 47
       $sequence1 = preg_split('/\R/', $string1);
48 48
       $sequence2 = preg_split('/\R/', $string2);
49 49
       $end1 = count($sequence1) - 1;
@@ -75,7 +75,9 @@  discard block
 block discarded – undo
75 75
     for ($index = 0; $index < $start; $index ++){
76 76
       $diff[] = array($sequence1[$index], self::UNMODIFIED);
77 77
     }
78
-    while (count($partialDiff) > 0) $diff[] = array_pop($partialDiff);
78
+    while (count($partialDiff) > 0) {
79
+        $diff[] = array_pop($partialDiff);
80
+    }
79 81
     for ($index = $end1 + 1;
80 82
         $index < ($compareCharacters ? strlen($sequence1) : count($sequence1));
81 83
         $index ++){
@@ -137,7 +139,7 @@  discard block
 block discarded – undo
137 139
         if ($sequence1[$index1 + $start - 1]
138 140
             == $sequence2[$index2 + $start - 1]){
139 141
           $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1;
140
-        }else{
142
+        } else{
141 143
           $table[$index1][$index2] =
142 144
               max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]);
143 145
         }
@@ -181,14 +183,14 @@  discard block
 block discarded – undo
181 183
         $index1 --;
182 184
         $index2 --;
183 185
 
184
-      }elseif ($index2 > 0
186
+      } elseif ($index2 > 0
185 187
           && $table[$index1][$index2] == $table[$index1][$index2 - 1]){
186 188
 
187 189
         // update the diff and the indices
188 190
         $diff[] = array($sequence2[$index2 + $start - 1], self::INSERTED);
189 191
         $index2 --;
190 192
 
191
-      }else{
193
+      } else{
192 194
 
193 195
         // update the diff and the indices
194 196
         $diff[] = array($sequence1[$index1 + $start - 1], self::DELETED);
Please login to merge, or discard this patch.
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Diff{
22 22
 
23
-  // define the constants
24
-  const UNMODIFIED = 0;
25
-  const DELETED    = 1;
26
-  const INSERTED   = 2;
23
+    // define the constants
24
+    const UNMODIFIED = 0;
25
+    const DELETED    = 1;
26
+    const INSERTED   = 2;
27 27
 
28
-  /* Returns the diff for two strings. The return value is an array, each of
28
+    /* Returns the diff for two strings. The return value is an array, each of
29 29
    * whose values is an array containing two values: a line (or character, if
30 30
    * $compareCharacters is true), and one of the constants DIFF::UNMODIFIED (the
31 31
    * line or character is in both strings), DIFF::DELETED (the line or character
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
    * $compareCharacters - true to compare characters, and false to compare
38 38
    *                      lines; this optional parameter defaults to false
39 39
    */
40
-  public static function compare(
41
-      $string1, $string2, $compareCharacters = false){
40
+    public static function compare(
41
+        $string1, $string2, $compareCharacters = false){
42 42
 
43 43
     // initialise the sequences and comparison start and end positions
44 44
     $start = 0;
45 45
     if ($compareCharacters){
46
-      $sequence1 = $string1;
47
-      $sequence2 = $string2;
48
-      $end1 = strlen($string1) - 1;
49
-      $end2 = strlen($string2) - 1;
46
+        $sequence1 = $string1;
47
+        $sequence2 = $string2;
48
+        $end1 = strlen($string1) - 1;
49
+        $end2 = strlen($string2) - 1;
50 50
     }else{
51
-      $sequence1 = preg_split('/\R/', $string1);
52
-      $sequence2 = preg_split('/\R/', $string2);
53
-      $end1 = count($sequence1) - 1;
54
-      $end2 = count($sequence2) - 1;
51
+        $sequence1 = preg_split('/\R/', $string1);
52
+        $sequence2 = preg_split('/\R/', $string2);
53
+        $end1 = count($sequence1) - 1;
54
+        $end2 = count($sequence2) - 1;
55 55
     }
56 56
 
57 57
     // skip any common prefix
58 58
     while ($start <= $end1 && $start <= $end2
59 59
         && $sequence1[$start] == $sequence2[$start]){
60
-      $start ++;
60
+        $start ++;
61 61
     }
62 62
 
63 63
     // skip any common suffix
64 64
     while ($end1 >= $start && $end2 >= $start
65 65
         && $sequence1[$end1] == $sequence2[$end2]){
66
-      $end1 --;
67
-      $end2 --;
66
+        $end1 --;
67
+        $end2 --;
68 68
     }
69 69
 
70 70
     // compute the table of longest common subsequence lengths
@@ -77,29 +77,29 @@  discard block
 block discarded – undo
77 77
     // generate the full diff
78 78
     $diff = array();
79 79
     for ($index = 0; $index < $start; $index ++){
80
-      $diff[] = array($sequence1[$index], self::UNMODIFIED);
80
+        $diff[] = array($sequence1[$index], self::UNMODIFIED);
81 81
     }
82 82
     while (count($partialDiff) > 0) $diff[] = array_pop($partialDiff);
83 83
     for ($index = $end1 + 1;
84 84
         $index < ($compareCharacters ? strlen($sequence1) : count($sequence1));
85 85
         $index ++){
86
-      $diff[] = array($sequence1[$index], self::UNMODIFIED);
86
+        $diff[] = array($sequence1[$index], self::UNMODIFIED);
87 87
     }
88 88
 
89 89
     // return the diff
90 90
     return $diff;
91 91
 
92
-  }
92
+    }
93 93
 
94
-  /* Returns the diff for two files. The parameters are:
94
+    /* Returns the diff for two files. The parameters are:
95 95
    *
96 96
    * $file1             - the path to the first file
97 97
    * $file2             - the path to the second file
98 98
    * $compareCharacters - true to compare characters, and false to compare
99 99
    *                      lines; this optional parameter defaults to false
100 100
    */
101
-  public static function compareFiles(
102
-      $file1, $file2, $compareCharacters = false){
101
+    public static function compareFiles(
102
+        $file1, $file2, $compareCharacters = false){
103 103
 
104 104
     // return the diff of the files
105 105
     return self::compare(
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
         file_get_contents($file2),
108 108
         $compareCharacters);
109 109
 
110
-  }
110
+    }
111 111
 
112
-  /* Returns the table of longest common subsequence lengths for the specified
112
+    /* Returns the table of longest common subsequence lengths for the specified
113 113
    * sequences. The parameters are:
114 114
    *
115 115
    * $sequence1 - the first sequence
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
    * $end1      - the ending index for the first sequence
119 119
    * $end2      - the ending index for the second sequence
120 120
    */
121
-  private static function computeTable(
122
-      $sequence1, $sequence2, $start, $end1, $end2){
121
+    private static function computeTable(
122
+        $sequence1, $sequence2, $start, $end1, $end2){
123 123
 
124 124
     // determine the lengths to be compared
125 125
     $length1 = $end1 - $start + 1;
@@ -131,30 +131,30 @@  discard block
 block discarded – undo
131 131
     // loop over the rows
132 132
     for ($index1 = 1; $index1 <= $length1; $index1 ++){
133 133
 
134
-      // create the new row
135
-      $table[$index1] = array(0);
134
+        // create the new row
135
+        $table[$index1] = array(0);
136 136
 
137
-      // loop over the columns
138
-      for ($index2 = 1; $index2 <= $length2; $index2 ++){
137
+        // loop over the columns
138
+        for ($index2 = 1; $index2 <= $length2; $index2 ++){
139 139
 
140 140
         // store the longest common subsequence length
141 141
         if ($sequence1[$index1 + $start - 1]
142 142
             == $sequence2[$index2 + $start - 1]){
143
-          $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1;
143
+            $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1;
144 144
         }else{
145
-          $table[$index1][$index2] =
146
-              max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]);
145
+            $table[$index1][$index2] =
146
+                max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]);
147 147
         }
148 148
 
149
-      }
149
+        }
150 150
     }
151 151
 
152 152
     // return the table
153 153
     return $table;
154 154
 
155
-  }
155
+    }
156 156
 
157
-  /* Returns the partial diff for the specificed sequences, in reverse order.
157
+    /* Returns the partial diff for the specificed sequences, in reverse order.
158 158
    * The parameters are:
159 159
    *
160 160
    * $table     - the table returned by the computeTable function
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
    * $sequence2 - the second sequence
163 163
    * $start     - the starting index
164 164
    */
165
-  private static function generatePartialDiff(
166
-      $table, $sequence1, $sequence2, $start){
165
+    private static function generatePartialDiff(
166
+        $table, $sequence1, $sequence2, $start){
167 167
 
168 168
     //  initialise the diff
169 169
     $diff = array();
@@ -175,39 +175,39 @@  discard block
 block discarded – undo
175 175
     // loop until there are no items remaining in either sequence
176 176
     while ($index1 > 0 || $index2 > 0){
177 177
 
178
-      // check what has happened to the items at these indices
179
-      if ($index1 > 0 && $index2 > 0
178
+        // check what has happened to the items at these indices
179
+        if ($index1 > 0 && $index2 > 0
180 180
           && $sequence1[$index1 + $start - 1]
181
-              == $sequence2[$index2 + $start - 1]){
181
+                == $sequence2[$index2 + $start - 1]){
182 182
 
183 183
         // update the diff and the indices
184 184
         $diff[] = array($sequence1[$index1 + $start - 1], self::UNMODIFIED);
185 185
         $index1 --;
186 186
         $index2 --;
187 187
 
188
-      }elseif ($index2 > 0
188
+        }elseif ($index2 > 0
189 189
           && $table[$index1][$index2] == $table[$index1][$index2 - 1]){
190 190
 
191 191
         // update the diff and the indices
192 192
         $diff[] = array($sequence2[$index2 + $start - 1], self::INSERTED);
193 193
         $index2 --;
194 194
 
195
-      }else{
195
+        }else{
196 196
 
197 197
         // update the diff and the indices
198 198
         $diff[] = array($sequence1[$index1 + $start - 1], self::DELETED);
199 199
         $index1 --;
200 200
 
201
-      }
201
+        }
202 202
 
203 203
     }
204 204
 
205 205
     // return the diff
206 206
     return $diff;
207 207
 
208
-  }
208
+    }
209 209
 
210
-  /* Returns a diff as a string, where unmodified lines are prefixed by '  ',
210
+    /* Returns a diff as a string, where unmodified lines are prefixed by '  ',
211 211
    * deletions are prefixed by '- ', and insertions are prefixed by '+ '. The
212 212
    * parameters are:
213 213
    *
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
    * $separator - the separator between lines; this optional parameter defaults
216 216
    *              to "\n"
217 217
    */
218
-  public static function toString($diff, $separator = "\n"){
218
+    public static function toString($diff, $separator = "\n"){
219 219
 
220 220
     // initialise the string
221 221
     $string = '';
@@ -223,24 +223,24 @@  discard block
 block discarded – undo
223 223
     // loop over the lines in the diff
224 224
     foreach ($diff as $line){
225 225
 
226
-      // extend the string with the line
227
-      switch ($line[1]){
226
+        // extend the string with the line
227
+        switch ($line[1]){
228 228
         case self::UNMODIFIED : $string .= '  ' . $line[0];break;
229 229
         case self::DELETED    : $string .= '- ' . $line[0];break;
230 230
         case self::INSERTED   : $string .= '+ ' . $line[0];break;
231
-      }
231
+        }
232 232
 
233
-      // extend the string with the separator
234
-      $string .= $separator;
233
+        // extend the string with the separator
234
+        $string .= $separator;
235 235
 
236 236
     }
237 237
 
238 238
     // return the string
239 239
     return $string;
240 240
 
241
-  }
241
+    }
242 242
 
243
-  /* Returns a diff as an HTML string, where unmodified lines are contained
243
+    /* Returns a diff as an HTML string, where unmodified lines are contained
244 244
    * within 'span' elements, deletions are contained within 'del' elements, and
245 245
    * insertions are contained within 'ins' elements. The parameters are:
246 246
    *
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
    * $separator - the separator between lines; this optional parameter defaults
249 249
    *              to '<br>'
250 250
    */
251
-  public static function toHTML($diff, $separator = '<br>'){
251
+    public static function toHTML($diff, $separator = '<br>'){
252 252
 
253 253
     // initialise the HTML
254 254
     $html = '';
@@ -256,28 +256,28 @@  discard block
 block discarded – undo
256 256
     // loop over the lines in the diff
257 257
     foreach ($diff as $line){
258 258
 
259
-      // extend the HTML with the line
260
-      switch ($line[1]){
259
+        // extend the HTML with the line
260
+        switch ($line[1]){
261 261
         case self::UNMODIFIED : $element = 'span'; break;
262 262
         case self::DELETED    : $element = 'del';  break;
263 263
         case self::INSERTED   : $element = 'ins';  break;
264
-      }
265
-      $html .=
266
-          '<' . $element . '>'
267
-          . htmlspecialchars($line[0])
268
-          . '</' . $element . '>';
264
+        }
265
+        $html .=
266
+            '<' . $element . '>'
267
+            . htmlspecialchars($line[0])
268
+            . '</' . $element . '>';
269 269
 
270
-      // extend the HTML with the separator
271
-      $html .= $separator;
270
+        // extend the HTML with the separator
271
+        $html .= $separator;
272 272
 
273 273
     }
274 274
 
275 275
     // return the HTML
276 276
     return $html;
277 277
 
278
-  }
278
+    }
279 279
 
280
-  /* Returns a diff as an HTML table. The parameters are:
280
+    /* Returns a diff as an HTML table. The parameters are:
281 281
    *
282 282
    * $diff        - the diff array
283 283
    * $indentation - indentation to add to every line of the generated HTML; this
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
    * $separator   - the separator between lines; this optional parameter
286 286
    *                defaults to '<br>'
287 287
    */
288
-  public static function toTable($diff, $indentation = '', $separator = '<br>'){
288
+    public static function toTable($diff, $indentation = '', $separator = '<br>'){
289 289
 
290 290
     // initialise the HTML
291 291
     $html = $indentation . "<table class=\"diff\">\n";
@@ -294,68 +294,68 @@  discard block
 block discarded – undo
294 294
     $index = 0;
295 295
     while ($index < count($diff)){
296 296
 
297
-      // determine the line type
298
-      switch ($diff[$index][1]){
297
+        // determine the line type
298
+        switch ($diff[$index][1]){
299 299
 
300 300
         // display the content on the left and right
301 301
         case self::UNMODIFIED:
302 302
           $leftCell =
303
-              self::getCellContent(
304
-                  $diff, $indentation, $separator, $index, self::UNMODIFIED);
305
-          $rightCell = $leftCell;
306
-          break;
303
+                self::getCellContent(
304
+                    $diff, $indentation, $separator, $index, self::UNMODIFIED);
305
+            $rightCell = $leftCell;
306
+            break;
307 307
 
308 308
         // display the deleted on the left and inserted content on the right
309 309
         case self::DELETED:
310 310
           $leftCell =
311
-              self::getCellContent(
312
-                  $diff, $indentation, $separator, $index, self::DELETED);
313
-          $rightCell =
314
-              self::getCellContent(
315
-                  $diff, $indentation, $separator, $index, self::INSERTED);
316
-          break;
311
+                self::getCellContent(
312
+                    $diff, $indentation, $separator, $index, self::DELETED);
313
+            $rightCell =
314
+                self::getCellContent(
315
+                    $diff, $indentation, $separator, $index, self::INSERTED);
316
+            break;
317 317
 
318 318
         // display the inserted content on the right
319 319
         case self::INSERTED:
320 320
           $leftCell = '';
321
-          $rightCell =
322
-              self::getCellContent(
323
-                  $diff, $indentation, $separator, $index, self::INSERTED);
324
-          break;
325
-
326
-      }
327
-
328
-      // extend the HTML with the new row
329
-      $html .=
330
-          $indentation
331
-          . "  <tr>\n"
332
-          . $indentation
333
-          . '    <td class="diff'
334
-          . ($leftCell == $rightCell
321
+            $rightCell =
322
+                self::getCellContent(
323
+                    $diff, $indentation, $separator, $index, self::INSERTED);
324
+            break;
325
+
326
+        }
327
+
328
+        // extend the HTML with the new row
329
+        $html .=
330
+            $indentation
331
+            . "  <tr>\n"
332
+            . $indentation
333
+            . '    <td class="diff'
334
+            . ($leftCell == $rightCell
335 335
               ? 'Unmodified'
336 336
               : ($leftCell == '' ? 'Blank' : 'Deleted'))
337
-          . '">'
338
-          . $leftCell
339
-          . "</td>\n"
340
-          . $indentation
341
-          . '    <td class="diff'
342
-          . ($leftCell == $rightCell
337
+            . '">'
338
+            . $leftCell
339
+            . "</td>\n"
340
+            . $indentation
341
+            . '    <td class="diff'
342
+            . ($leftCell == $rightCell
343 343
               ? 'Unmodified'
344 344
               : ($rightCell == '' ? 'Blank' : 'Inserted'))
345
-          . '">'
346
-          . $rightCell
347
-          . "</td>\n"
348
-          . $indentation
349
-          . "  </tr>\n";
345
+            . '">'
346
+            . $rightCell
347
+            . "</td>\n"
348
+            . $indentation
349
+            . "  </tr>\n";
350 350
 
351 351
     }
352 352
 
353 353
     // return the HTML
354 354
     return $html . $indentation . "</table>\n";
355 355
 
356
-  }
356
+    }
357 357
 
358
-  /* Returns the content of the cell, for use in the toTable function. The
358
+    /* Returns the content of the cell, for use in the toTable function. The
359 359
    * parameters are:
360 360
    *
361 361
    * $diff        - the diff array
@@ -364,25 +364,25 @@  discard block
 block discarded – undo
364 364
    * $index       - the current index, passes by reference
365 365
    * $type        - the type of line
366 366
    */
367
-  private static function getCellContent(
368
-      $diff, $indentation, $separator, &$index, $type){
367
+    private static function getCellContent(
368
+        $diff, $indentation, $separator, &$index, $type){
369 369
 
370 370
     // initialise the HTML
371 371
     $html = '';
372 372
 
373 373
     // loop over the matching lines, adding them to the HTML
374 374
     while ($index < count($diff) && $diff[$index][1] == $type){
375
-      $html .=
376
-          '<span>'
377
-          . htmlspecialchars($diff[$index][0])
378
-          . '</span>'
379
-          . $separator;
380
-      $index ++;
375
+        $html .=
376
+            '<span>'
377
+            . htmlspecialchars($diff[$index][0])
378
+            . '</span>'
379
+            . $separator;
380
+        $index ++;
381 381
     }
382 382
 
383 383
     // return the HTML
384 384
     return $html;
385 385
 
386
-  }
386
+    }
387 387
 
388 388
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * @codeCoverageIgnore
19 19
  * Third party library
20 20
  */
21
-class Diff{
21
+class Diff {
22 22
 
23 23
   // define the constants
24 24
   const UNMODIFIED = 0;
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
    *                      lines; this optional parameter defaults to false
39 39
    */
40 40
   public static function compare(
41
-      $string1, $string2, $compareCharacters = false){
41
+      $string1, $string2, $compareCharacters = false) {
42 42
 
43 43
     // initialise the sequences and comparison start and end positions
44 44
     $start = 0;
45
-    if ($compareCharacters){
45
+    if ($compareCharacters) {
46 46
       $sequence1 = $string1;
47 47
       $sequence2 = $string2;
48 48
       $end1 = strlen($string1) - 1;
49 49
       $end2 = strlen($string2) - 1;
50
-    }else{
50
+    } else {
51 51
       $sequence1 = preg_split('/\R/', $string1);
52 52
       $sequence2 = preg_split('/\R/', $string2);
53 53
       $end1 = count($sequence1) - 1;
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
 
57 57
     // skip any common prefix
58 58
     while ($start <= $end1 && $start <= $end2
59
-        && $sequence1[$start] == $sequence2[$start]){
60
-      $start ++;
59
+        && $sequence1[$start] == $sequence2[$start]) {
60
+      $start++;
61 61
     }
62 62
 
63 63
     // skip any common suffix
64 64
     while ($end1 >= $start && $end2 >= $start
65
-        && $sequence1[$end1] == $sequence2[$end2]){
66
-      $end1 --;
67
-      $end2 --;
65
+        && $sequence1[$end1] == $sequence2[$end2]) {
66
+      $end1--;
67
+      $end2--;
68 68
     }
69 69
 
70 70
     // compute the table of longest common subsequence lengths
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
 
77 77
     // generate the full diff
78 78
     $diff = array();
79
-    for ($index = 0; $index < $start; $index ++){
79
+    for ($index = 0; $index < $start; $index++) {
80 80
       $diff[] = array($sequence1[$index], self::UNMODIFIED);
81 81
     }
82 82
     while (count($partialDiff) > 0) $diff[] = array_pop($partialDiff);
83 83
     for ($index = $end1 + 1;
84 84
         $index < ($compareCharacters ? strlen($sequence1) : count($sequence1));
85
-        $index ++){
85
+        $index++) {
86 86
       $diff[] = array($sequence1[$index], self::UNMODIFIED);
87 87
     }
88 88
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
    *                      lines; this optional parameter defaults to false
100 100
    */
101 101
   public static function compareFiles(
102
-      $file1, $file2, $compareCharacters = false){
102
+      $file1, $file2, $compareCharacters = false) {
103 103
 
104 104
     // return the diff of the files
105 105
     return self::compare(
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
    * $end2      - the ending index for the second sequence
120 120
    */
121 121
   private static function computeTable(
122
-      $sequence1, $sequence2, $start, $end1, $end2){
122
+      $sequence1, $sequence2, $start, $end1, $end2) {
123 123
 
124 124
     // determine the lengths to be compared
125 125
     $length1 = $end1 - $start + 1;
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
     $table = array(array_fill(0, $length2 + 1, 0));
130 130
 
131 131
     // loop over the rows
132
-    for ($index1 = 1; $index1 <= $length1; $index1 ++){
132
+    for ($index1 = 1; $index1 <= $length1; $index1++) {
133 133
 
134 134
       // create the new row
135 135
       $table[$index1] = array(0);
136 136
 
137 137
       // loop over the columns
138
-      for ($index2 = 1; $index2 <= $length2; $index2 ++){
138
+      for ($index2 = 1; $index2 <= $length2; $index2++) {
139 139
 
140 140
         // store the longest common subsequence length
141 141
         if ($sequence1[$index1 + $start - 1]
142
-            == $sequence2[$index2 + $start - 1]){
142
+            == $sequence2[$index2 + $start - 1]) {
143 143
           $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1;
144
-        }else{
144
+        } else {
145 145
           $table[$index1][$index2] =
146 146
               max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]);
147 147
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
    * $start     - the starting index
164 164
    */
165 165
   private static function generatePartialDiff(
166
-      $table, $sequence1, $sequence2, $start){
166
+      $table, $sequence1, $sequence2, $start) {
167 167
 
168 168
     //  initialise the diff
169 169
     $diff = array();
@@ -173,30 +173,30 @@  discard block
 block discarded – undo
173 173
     $index2 = count($table[0]) - 1;
174 174
 
175 175
     // loop until there are no items remaining in either sequence
176
-    while ($index1 > 0 || $index2 > 0){
176
+    while ($index1 > 0 || $index2 > 0) {
177 177
 
178 178
       // check what has happened to the items at these indices
179 179
       if ($index1 > 0 && $index2 > 0
180 180
           && $sequence1[$index1 + $start - 1]
181
-              == $sequence2[$index2 + $start - 1]){
181
+              == $sequence2[$index2 + $start - 1]) {
182 182
 
183 183
         // update the diff and the indices
184 184
         $diff[] = array($sequence1[$index1 + $start - 1], self::UNMODIFIED);
185
-        $index1 --;
186
-        $index2 --;
185
+        $index1--;
186
+        $index2--;
187 187
 
188 188
       }elseif ($index2 > 0
189
-          && $table[$index1][$index2] == $table[$index1][$index2 - 1]){
189
+          && $table[$index1][$index2] == $table[$index1][$index2 - 1]) {
190 190
 
191 191
         // update the diff and the indices
192 192
         $diff[] = array($sequence2[$index2 + $start - 1], self::INSERTED);
193
-        $index2 --;
193
+        $index2--;
194 194
 
195
-      }else{
195
+      } else {
196 196
 
197 197
         // update the diff and the indices
198 198
         $diff[] = array($sequence1[$index1 + $start - 1], self::DELETED);
199
-        $index1 --;
199
+        $index1--;
200 200
 
201 201
       }
202 202
 
@@ -215,19 +215,19 @@  discard block
 block discarded – undo
215 215
    * $separator - the separator between lines; this optional parameter defaults
216 216
    *              to "\n"
217 217
    */
218
-  public static function toString($diff, $separator = "\n"){
218
+  public static function toString($diff, $separator = "\n") {
219 219
 
220 220
     // initialise the string
221 221
     $string = '';
222 222
 
223 223
     // loop over the lines in the diff
224
-    foreach ($diff as $line){
224
+    foreach ($diff as $line) {
225 225
 
226 226
       // extend the string with the line
227
-      switch ($line[1]){
228
-        case self::UNMODIFIED : $string .= '  ' . $line[0];break;
229
-        case self::DELETED    : $string .= '- ' . $line[0];break;
230
-        case self::INSERTED   : $string .= '+ ' . $line[0];break;
227
+      switch ($line[1]) {
228
+        case self::UNMODIFIED : $string .= '  ' . $line[0]; break;
229
+        case self::DELETED    : $string .= '- ' . $line[0]; break;
230
+        case self::INSERTED   : $string .= '+ ' . $line[0]; break;
231 231
       }
232 232
 
233 233
       // extend the string with the separator
@@ -248,19 +248,19 @@  discard block
 block discarded – undo
248 248
    * $separator - the separator between lines; this optional parameter defaults
249 249
    *              to '<br>'
250 250
    */
251
-  public static function toHTML($diff, $separator = '<br>'){
251
+  public static function toHTML($diff, $separator = '<br>') {
252 252
 
253 253
     // initialise the HTML
254 254
     $html = '';
255 255
 
256 256
     // loop over the lines in the diff
257
-    foreach ($diff as $line){
257
+    foreach ($diff as $line) {
258 258
 
259 259
       // extend the HTML with the line
260
-      switch ($line[1]){
260
+      switch ($line[1]) {
261 261
         case self::UNMODIFIED : $element = 'span'; break;
262
-        case self::DELETED    : $element = 'del';  break;
263
-        case self::INSERTED   : $element = 'ins';  break;
262
+        case self::DELETED    : $element = 'del'; break;
263
+        case self::INSERTED   : $element = 'ins'; break;
264 264
       }
265 265
       $html .=
266 266
           '<' . $element . '>'
@@ -285,17 +285,17 @@  discard block
 block discarded – undo
285 285
    * $separator   - the separator between lines; this optional parameter
286 286
    *                defaults to '<br>'
287 287
    */
288
-  public static function toTable($diff, $indentation = '', $separator = '<br>'){
288
+  public static function toTable($diff, $indentation = '', $separator = '<br>') {
289 289
 
290 290
     // initialise the HTML
291 291
     $html = $indentation . "<table class=\"diff\">\n";
292 292
 
293 293
     // loop over the lines in the diff
294 294
     $index = 0;
295
-    while ($index < count($diff)){
295
+    while ($index < count($diff)) {
296 296
 
297 297
       // determine the line type
298
-      switch ($diff[$index][1]){
298
+      switch ($diff[$index][1]) {
299 299
 
300 300
         // display the content on the left and right
301 301
         case self::UNMODIFIED:
@@ -365,19 +365,19 @@  discard block
 block discarded – undo
365 365
    * $type        - the type of line
366 366
    */
367 367
   private static function getCellContent(
368
-      $diff, $indentation, $separator, &$index, $type){
368
+      $diff, $indentation, $separator, &$index, $type) {
369 369
 
370 370
     // initialise the HTML
371 371
     $html = '';
372 372
 
373 373
     // loop over the matching lines, adding them to the HTML
374
-    while ($index < count($diff) && $diff[$index][1] == $type){
374
+    while ($index < count($diff) && $diff[$index][1] == $type) {
375 375
       $html .=
376 376
           '<span>'
377 377
           . htmlspecialchars($diff[$index][0])
378 378
           . '</span>'
379 379
           . $separator;
380
-      $index ++;
380
+      $index++;
381 381
     }
382 382
 
383 383
     // return the HTML
Please login to merge, or discard this patch.
app/filesystem/Filesystem.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@
 block discarded – undo
26 26
             $it = new \RecursiveDirectoryIterator($filename_clean, \RecursiveDirectoryIterator::SKIP_DOTS);
27 27
             $files = new \RecursiveIteratorIterator($it,
28 28
                         \RecursiveIteratorIterator::CHILD_FIRST);
29
-            foreach($files as $file) {
30
-                if ($file->isDir()){
29
+            foreach ($files as $file) {
30
+                if ($file->isDir()) {
31 31
                     rmdir($file->getRealPath());
32 32
                 } else {
33 33
                     unlink($file->getRealPath());
Please login to merge, or discard this patch.
app/generators/AddonXml/AddonXmlGenerator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -352,7 +352,7 @@
 block discarded – undo
352 352
             $settingItem->addChild('type', $type);
353 353
             if ($variants) {
354 354
                 $variantsElement = $settingItem->addChild('variants');
355
-                    foreach($variants as $variant)
355
+                    foreach ($variants as $variant)
356 356
                     {
357 357
                         $variantElement = $variantsElement->addChild('item');
358 358
                             $variantElement->addAttribute('id', $variant);
Please login to merge, or discard this patch.
app/helpers/string.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
             $key = $matches[1];
55 55
             $value = true;
56 56
 
57
-            switch(count($matches)) {
57
+            switch (count($matches)) {
58 58
                 case 4:
59 59
                 case 5:
60 60
                     $value = $matches[3];
Please login to merge, or discard this patch.
app/helpers/file.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@
 block discarded – undo
9 9
         if (
10 10
             ($prefix = substr($input, 0, 3)) == '../' ||
11 11
             ($prefix = substr($input, 0, 2)) == './'
12
-           ) {
12
+            ) {
13 13
             $input = substr($input, strlen($prefix));
14 14
         } else if (
15 15
             ($prefix = substr($input, 0, 3)) == '/./' ||
16 16
             ($prefix = $input) == '/.'
17
-           ) {
17
+            ) {
18 18
             $input = '/' . substr($input, strlen($prefix));
19 19
         } else
20 20
 
21 21
         if (
22 22
             ($prefix = substr($input, 0, 4)) == '/../' ||
23 23
             ($prefix = $input) == '/..'
24
-           ) {
24
+            ) {
25 25
             $input = '/' . substr($input, strlen($prefix));
26 26
             $output = substr($output, 0, strrpos($output, '/'));
27 27
         } else if ($input == '.' || $input == '..') {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
             $input = '';
29 29
         } else {
30 30
             $pos = strpos($input, '/');
31
-            if ($pos === 0) $pos = strpos($input, '/', $pos+1);
31
+            if ($pos === 0) $pos = strpos($input, '/', $pos + 1);
32 32
             if ($pos === false) $pos = strlen($input);
33 33
             $output .= substr($input, 0, $pos);
34 34
             $input = (string) substr($input, $pos);
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,12 @@
 block discarded – undo
28 28
             $input = '';
29 29
         } else {
30 30
             $pos = strpos($input, '/');
31
-            if ($pos === 0) $pos = strpos($input, '/', $pos+1);
32
-            if ($pos === false) $pos = strlen($input);
31
+            if ($pos === 0) {
32
+                $pos = strpos($input, '/', $pos+1);
33
+            }
34
+            if ($pos === false) {
35
+                $pos = strlen($input);
36
+            }
33 37
             $output .= substr($input, 0, $pos);
34 38
             $input = (string) substr($input, $pos);
35 39
         }
Please login to merge, or discard this patch.
ccg.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@
 block discarded – undo
10 10
 /**
11 11
  * autoload
12 12
  */
13
-spl_autoload_register(function ($class) {
13
+spl_autoload_register(function($class) {
14 14
     $file = realpath(__DIR__ . '/' . 'app') . '/' . str_replace('\\', '/', $class) . '.php';
15
-    if(file_exists($file)) {
15
+    if (file_exists($file)) {
16 16
         require_once($file);
17 17
     }
18 18
 });
Please login to merge, or discard this patch.
app/controllers/AddonXml.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@
 block discarded – undo
228 228
 
229 229
     public function setSettingsItemAutocomplete()
230 230
     {
231
-        $generator      = $this->mfGenerator
231
+        $generator = $this->mfGenerator
232 232
             ->find(AddonXmlGenerator::class)
233 233
                 ->extract();
234 234
 
Please login to merge, or discard this patch.
app/Config.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
             $self->set($key, $setting);
14 14
         });
15 15
         
16
-        foreach($arguments as $key => $value) {
16
+        foreach ($arguments as $key => $value) {
17 17
             $this->set($key, $value);
18 18
         }
19 19
     }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     public function getOr(string ...$keys)
37 37
     {
38
-        foreach($keys as $key) {
38
+        foreach ($keys as $key) {
39 39
             $value = $this->get($key);
40 40
 
41 41
             if ($value) {
Please login to merge, or discard this patch.
app/generators/Readme/ReadmeGenerator.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
 use mediators\AbstractMediator;
7 7
 
8 8
 /**
9
-  * @property string FILENAME
10
-  * @property string $content
11
-  * @property Config $config
12
-  */
9
+ * @property string FILENAME
10
+ * @property string $content
11
+ * @property Config $config
12
+ */
13 13
 final class ReadmeGenerator extends \generators\AbstractGenerator
14 14
 {
15 15
     const FILENAME = 'app/addons/${addon}/README.md';
Please login to merge, or discard this patch.