@@ -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'; |
@@ -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.', |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | // skip any common prefix |
202 | 202 | while ($start <= $end1 && $start <= $end2 && $this->sequence1[$start] == $this->sequence2[$start]) |
203 | 203 | { |
204 | - $start ++; |
|
204 | + $start++; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | // skip any common suffix |
208 | 208 | while ($end1 >= $start && $end2 >= $start && $this->sequence1[$end1] == $this->sequence2[$end2]) |
209 | 209 | { |
210 | - $end1 --; |
|
211 | - $end2 --; |
|
210 | + $end1--; |
|
211 | + $end2--; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // compute the table of longest common subsequence lengths |
@@ -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 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | $max = ($this->compareCharacters ? strlen($this->sequence1) : count($this->sequence1)); |
234 | 234 | |
235 | - for ($index = $end1 + 1; $index < $max; $index ++) |
|
235 | + for ($index = $end1 + 1; $index < $max; $index++) |
|
236 | 236 | { |
237 | 237 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
238 | 238 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | { |
255 | 255 | $split = preg_split('/\R/', $string); |
256 | 256 | |
257 | - if(is_array($split)) |
|
257 | + if (is_array($split)) |
|
258 | 258 | { |
259 | 259 | return $split; |
260 | 260 | } |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | $table = array(array_fill(0, $length2 + 1, 0)); |
286 | 286 | |
287 | 287 | // loop over the rows |
288 | - for ($index1 = 1; $index1 <= $length1; $index1 ++){ |
|
288 | + for ($index1 = 1; $index1 <= $length1; $index1++) { |
|
289 | 289 | |
290 | 290 | // create the new row |
291 | 291 | $table[$index1] = array(0); |
292 | 292 | |
293 | 293 | // loop over the columns |
294 | - for ($index2 = 1; $index2 <= $length2; $index2 ++){ |
|
294 | + for ($index2 = 1; $index2 <= $length2; $index2++) { |
|
295 | 295 | |
296 | 296 | // store the longest common subsequence length |
297 | 297 | if ($this->sequence1[$index1 + $start - 1] |
298 | - == $this->sequence2[$index2 + $start - 1]){ |
|
298 | + == $this->sequence2[$index2 + $start - 1]) { |
|
299 | 299 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; |
300 | - }else{ |
|
300 | + } else { |
|
301 | 301 | $table[$index1][$index2] = |
302 | 302 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); |
303 | 303 | } |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | $index1 > 0 && $index2 > 0 |
333 | 333 | && $this->sequence1[$index1 + $start - 1] |
334 | 334 | == $this->sequence2[$index2 + $start - 1] |
335 | - ){ |
|
335 | + ) { |
|
336 | 336 | // update the diff and the indices |
337 | 337 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::UNMODIFIED); |
338 | - $index1 --; |
|
339 | - $index2 --; |
|
338 | + $index1--; |
|
339 | + $index2--; |
|
340 | 340 | } |
341 | 341 | elseif ( |
342 | 342 | $index2 > 0 |
@@ -344,13 +344,13 @@ discard block |
||
344 | 344 | ) { |
345 | 345 | // update the diff and the indices |
346 | 346 | $diff[] = array($this->sequence2[$index2 + $start - 1], self::INSERTED); |
347 | - $index2 --; |
|
347 | + $index2--; |
|
348 | 348 | } |
349 | 349 | else |
350 | 350 | { |
351 | 351 | // update the diff and the indices |
352 | 352 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::DELETED); |
353 | - $index1 --; |
|
353 | + $index1--; |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 |