@@ -41,7 +41,7 @@ |
||
| 41 | 41 | $folder = sprintf(__DIR__.'/../../css/%s', $this->fileName); |
| 42 | 42 | $path = realpath($folder); |
| 43 | 43 | |
| 44 | - if($path === false) |
|
| 44 | + if ($path === false) |
|
| 45 | 45 | { |
| 46 | 46 | throw new DiffException( |
| 47 | 47 | 'Could not find the highlight CSS file', |
@@ -48,8 +48,8 @@ |
||
| 48 | 48 | switch ($line[1]) |
| 49 | 49 | { |
| 50 | 50 | case Diff::UNMODIFIED : $element = 'span'; break; |
| 51 | - case Diff::DELETED : $element = 'del'; break; |
|
| 52 | - case Diff::INSERTED : $element = 'ins'; break; |
|
| 51 | + case Diff::DELETED : $element = 'del'; break; |
|
| 52 | + case Diff::INSERTED : $element = 'ins'; break; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $html .= sprintf( |
@@ -36,9 +36,9 @@ |
||
| 36 | 36 | // extend the string with the line |
| 37 | 37 | switch ($line[1]) |
| 38 | 38 | { |
| 39 | - case Diff::UNMODIFIED : $string .= ' ' . $line[0];break; |
|
| 40 | - case Diff::DELETED : $string .= '- ' . $line[0];break; |
|
| 41 | - case Diff::INSERTED : $string .= '+ ' . $line[0];break; |
|
| 39 | + case Diff::UNMODIFIED : $string .= ' '.$line[0]; break; |
|
| 40 | + case Diff::DELETED : $string .= '- '.$line[0]; break; |
|
| 41 | + case Diff::INSERTED : $string .= '+ '.$line[0]; break; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // extend the string with the separator |
@@ -149,24 +149,24 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | // extend the HTML with the new row |
| 151 | 151 | $html .= |
| 152 | - $i2. "<tr>". $nl . |
|
| 153 | - $i3. '<td class="text-diff-'.$leftType. '">'. $leftCell . "</td>".$nl. |
|
| 154 | - $i3. '<td class="text-diff-'.$rightType. '">'. $rightCell . "</td>".$nl. |
|
| 155 | - $i2. "</tr>".$nl; |
|
| 152 | + $i2."<tr>".$nl. |
|
| 153 | + $i3.'<td class="text-diff-'.$leftType.'">'.$leftCell."</td>".$nl. |
|
| 154 | + $i3.'<td class="text-diff-'.$rightType.'">'.$rightCell."</td>".$nl. |
|
| 155 | + $i2."</tr>".$nl; |
|
| 156 | 156 | |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - return $i1. sprintf($this->container, $nl.$html).$nl; |
|
| 159 | + return $i1.sprintf($this->container, $nl.$html).$nl; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | private function resolveLeftType(string $leftCell, string $rightCell) : string |
| 163 | 163 | { |
| 164 | - if(empty($leftCell)) |
|
| 164 | + if (empty($leftCell)) |
|
| 165 | 165 | { |
| 166 | 166 | return 'empty'; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - else if($leftCell !== $rightCell) |
|
| 169 | + else if ($leftCell !== $rightCell) |
|
| 170 | 170 | { |
| 171 | 171 | return 'del'; |
| 172 | 172 | } |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | private function resolveRightType(string $leftCell, string $rightCell) : string |
| 178 | 178 | { |
| 179 | - if(empty($rightCell)) |
|
| 179 | + if (empty($rightCell)) |
|
| 180 | 180 | { |
| 181 | 181 | return 'empty'; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - else if($leftCell !== $rightCell) |
|
| 184 | + else if ($leftCell !== $rightCell) |
|
| 185 | 185 | { |
| 186 | 186 | return 'ins'; |
| 187 | 187 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $this->separator |
| 213 | 213 | ); |
| 214 | 214 | |
| 215 | - $index ++; |
|
| 215 | + $index++; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | return $html; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | private function resolveTag(int $type) : string |
| 222 | 222 | { |
| 223 | - switch($type) |
|
| 223 | + switch ($type) |
|
| 224 | 224 | { |
| 225 | 225 | case Diff::DELETED: return 'del'; |
| 226 | 226 | case Diff::INSERTED: return 'ins'; |
@@ -164,9 +164,7 @@ discard block |
||
| 164 | 164 | if(empty($leftCell)) |
| 165 | 165 | { |
| 166 | 166 | return 'empty'; |
| 167 | - } |
|
| 168 | - |
|
| 169 | - else if($leftCell !== $rightCell) |
|
| 167 | + } else if($leftCell !== $rightCell) |
|
| 170 | 168 | { |
| 171 | 169 | return 'del'; |
| 172 | 170 | } |
@@ -179,9 +177,7 @@ discard block |
||
| 179 | 177 | if(empty($rightCell)) |
| 180 | 178 | { |
| 181 | 179 | return 'empty'; |
| 182 | - } |
|
| 183 | - |
|
| 184 | - else if($leftCell !== $rightCell) |
|
| 180 | + } else if($leftCell !== $rightCell) |
|
| 185 | 181 | { |
| 186 | 182 | return 'ins'; |
| 187 | 183 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param bool $compare |
| 81 | 81 | * @return Diff |
| 82 | 82 | */ |
| 83 | - public function setCompareCharacters(bool $compare=true) : Diff |
|
| 83 | + public function setCompareCharacters(bool $compare = true) : Diff |
|
| 84 | 84 | { |
| 85 | 85 | $this->compareCharacters = $compare; |
| 86 | 86 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function toArray() : array |
| 173 | 173 | { |
| 174 | - if($this->disposed) |
|
| 174 | + if ($this->disposed) |
|
| 175 | 175 | { |
| 176 | 176 | throw new DiffException( |
| 177 | 177 | 'The diff has been disposed.', |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | // skip any common prefix |
| 205 | 205 | while ($start <= $end1 && $start <= $end2 && $this->sequence1[$start] == $this->sequence2[$start]) |
| 206 | 206 | { |
| 207 | - $start ++; |
|
| 207 | + $start++; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // skip any common suffix |
| 211 | 211 | while ($end1 >= $start && $end2 >= $start && $this->sequence1[$end1] == $this->sequence2[$end2]) |
| 212 | 212 | { |
| 213 | - $end1 --; |
|
| 214 | - $end2 --; |
|
| 213 | + $end1--; |
|
| 214 | + $end2--; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // generate the partial diff |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | // generate the full diff |
| 221 | 221 | $diff = array(); |
| 222 | 222 | |
| 223 | - for ($index = 0; $index < $start; $index ++) |
|
| 223 | + for ($index = 0; $index < $start; $index++) |
|
| 224 | 224 | { |
| 225 | 225 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
| 226 | 226 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $diff[] = array_pop($partialDiff); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - for ($index = $end1 + 1; $index < $totalSequence; $index ++) |
|
| 233 | + for ($index = $end1 + 1; $index < $totalSequence; $index++) |
|
| 234 | 234 | { |
| 235 | 235 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
| 236 | 236 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | $split = preg_split('/\R/', $string); |
| 255 | 255 | |
| 256 | - if(is_array($split)) |
|
| 256 | + if (is_array($split)) |
|
| 257 | 257 | { |
| 258 | 258 | return $split; |
| 259 | 259 | } |
@@ -284,19 +284,19 @@ discard block |
||
| 284 | 284 | $table = array(array_fill(0, $length2 + 1, 0)); |
| 285 | 285 | |
| 286 | 286 | // loop over the rows |
| 287 | - for ($index1 = 1; $index1 <= $length1; $index1 ++){ |
|
| 287 | + for ($index1 = 1; $index1 <= $length1; $index1++) { |
|
| 288 | 288 | |
| 289 | 289 | // create the new row |
| 290 | 290 | $table[$index1] = array(0); |
| 291 | 291 | |
| 292 | 292 | // loop over the columns |
| 293 | - for ($index2 = 1; $index2 <= $length2; $index2 ++){ |
|
| 293 | + for ($index2 = 1; $index2 <= $length2; $index2++) { |
|
| 294 | 294 | |
| 295 | 295 | // store the longest common subsequence length |
| 296 | 296 | if ($this->sequence1[$index1 + $start - 1] |
| 297 | - == $this->sequence2[$index2 + $start - 1]){ |
|
| 297 | + == $this->sequence2[$index2 + $start - 1]) { |
|
| 298 | 298 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; |
| 299 | - }else{ |
|
| 299 | + } else { |
|
| 300 | 300 | $table[$index1][$index2] = |
| 301 | 301 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); |
| 302 | 302 | } |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | $index1 > 0 && $index2 > 0 |
| 336 | 336 | && $this->sequence1[$index1 + $start - 1] |
| 337 | 337 | == $this->sequence2[$index2 + $start - 1] |
| 338 | - ){ |
|
| 338 | + ) { |
|
| 339 | 339 | // update the diff and the indices |
| 340 | 340 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::UNMODIFIED); |
| 341 | - $index1 --; |
|
| 342 | - $index2 --; |
|
| 341 | + $index1--; |
|
| 342 | + $index2--; |
|
| 343 | 343 | } |
| 344 | 344 | elseif ( |
| 345 | 345 | $index2 > 0 |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | ) { |
| 348 | 348 | // update the diff and the indices |
| 349 | 349 | $diff[] = array($this->sequence2[$index2 + $start - 1], self::INSERTED); |
| 350 | - $index2 --; |
|
| 350 | + $index2--; |
|
| 351 | 351 | } |
| 352 | 352 | else |
| 353 | 353 | { |
| 354 | 354 | // update the diff and the indices |
| 355 | 355 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::DELETED); |
| 356 | - $index1 --; |
|
| 356 | + $index1--; |
|
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
@@ -191,8 +191,7 @@ discard block |
||
| 191 | 191 | $end1 = strlen($this->string1) - 1; |
| 192 | 192 | $end2 = strlen($this->string2) - 1; |
| 193 | 193 | $totalSequence = strlen($this->sequence1); |
| 194 | - } |
|
| 195 | - else |
|
| 194 | + } else |
|
| 196 | 195 | { |
| 197 | 196 | $this->sequence1 = $this->splitString($this->string1); |
| 198 | 197 | $this->sequence2 = $this->splitString($this->string2); |
@@ -296,7 +295,7 @@ discard block |
||
| 296 | 295 | if ($this->sequence1[$index1 + $start - 1] |
| 297 | 296 | == $this->sequence2[$index2 + $start - 1]){ |
| 298 | 297 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; |
| 299 | - }else{ |
|
| 298 | + } else{ |
|
| 300 | 299 | $table[$index1][$index2] = |
| 301 | 300 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); |
| 302 | 301 | } |
@@ -340,16 +339,14 @@ discard block |
||
| 340 | 339 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::UNMODIFIED); |
| 341 | 340 | $index1 --; |
| 342 | 341 | $index2 --; |
| 343 | - } |
|
| 344 | - elseif ( |
|
| 342 | + } elseif ( |
|
| 345 | 343 | $index2 > 0 |
| 346 | 344 | && $table[$index1][$index2] == $table[$index1][$index2 - 1] |
| 347 | 345 | ) { |
| 348 | 346 | // update the diff and the indices |
| 349 | 347 | $diff[] = array($this->sequence2[$index2 + $start - 1], self::INSERTED); |
| 350 | 348 | $index2 --; |
| 351 | - } |
|
| 352 | - else |
|
| 349 | + } else |
|
| 353 | 350 | { |
| 354 | 351 | // update the diff and the indices |
| 355 | 352 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::DELETED); |