@@ -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'; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param bool $compare |
80 | 80 | * @return Diff |
81 | 81 | */ |
82 | - public function setCompareCharacters(bool $compare=true) : Diff |
|
82 | + public function setCompareCharacters(bool $compare = true) : Diff |
|
83 | 83 | { |
84 | 84 | $this->compareCharacters = $compare; |
85 | 85 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function toArray() : array |
172 | 172 | { |
173 | - if($this->disposed) |
|
173 | + if ($this->disposed) |
|
174 | 174 | { |
175 | 175 | throw new DiffException( |
176 | 176 | 'The diff has been disposed.', |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | // skip any common prefix |
201 | 201 | while ($start <= $end1 && $start <= $end2 && $this->sequence1[$start] == $this->sequence2[$start]) |
202 | 202 | { |
203 | - $start ++; |
|
203 | + $start++; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | // skip any common suffix |
207 | 207 | while ($end1 >= $start && $end2 >= $start && $this->sequence1[$end1] == $this->sequence2[$end2]) |
208 | 208 | { |
209 | - $end1 --; |
|
210 | - $end2 --; |
|
209 | + $end1--; |
|
210 | + $end2--; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | // compute the table of longest common subsequence lengths |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | // generate the full diff |
220 | 220 | $diff = array(); |
221 | 221 | |
222 | - for ($index = 0; $index < $start; $index ++) |
|
222 | + for ($index = 0; $index < $start; $index++) |
|
223 | 223 | { |
224 | 224 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
225 | 225 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | $max = ($this->compareCharacters ? strlen($this->sequence1) : count($this->sequence1)); |
233 | 233 | |
234 | - for ($index = $end1 + 1; $index < $max; $index ++) |
|
234 | + for ($index = $end1 + 1; $index < $max; $index++) |
|
235 | 235 | { |
236 | 236 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
237 | 237 | } |
@@ -261,19 +261,19 @@ discard block |
||
261 | 261 | $table = array(array_fill(0, $length2 + 1, 0)); |
262 | 262 | |
263 | 263 | // loop over the rows |
264 | - for ($index1 = 1; $index1 <= $length1; $index1 ++){ |
|
264 | + for ($index1 = 1; $index1 <= $length1; $index1++) { |
|
265 | 265 | |
266 | 266 | // create the new row |
267 | 267 | $table[$index1] = array(0); |
268 | 268 | |
269 | 269 | // loop over the columns |
270 | - for ($index2 = 1; $index2 <= $length2; $index2 ++){ |
|
270 | + for ($index2 = 1; $index2 <= $length2; $index2++) { |
|
271 | 271 | |
272 | 272 | // store the longest common subsequence length |
273 | 273 | if ($this->sequence1[$index1 + $start - 1] |
274 | - == $this->sequence2[$index2 + $start - 1]){ |
|
274 | + == $this->sequence2[$index2 + $start - 1]) { |
|
275 | 275 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; |
276 | - }else{ |
|
276 | + } else { |
|
277 | 277 | $table[$index1][$index2] = |
278 | 278 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); |
279 | 279 | } |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | $index1 > 0 && $index2 > 0 |
309 | 309 | && $this->sequence1[$index1 + $start - 1] |
310 | 310 | == $this->sequence2[$index2 + $start - 1] |
311 | - ){ |
|
311 | + ) { |
|
312 | 312 | // update the diff and the indices |
313 | 313 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::UNMODIFIED); |
314 | - $index1 --; |
|
315 | - $index2 --; |
|
314 | + $index1--; |
|
315 | + $index2--; |
|
316 | 316 | } |
317 | 317 | elseif ( |
318 | 318 | $index2 > 0 |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | ) { |
321 | 321 | // update the diff and the indices |
322 | 322 | $diff[] = array($this->sequence2[$index2 + $start - 1], self::INSERTED); |
323 | - $index2 --; |
|
323 | + $index2--; |
|
324 | 324 | } |
325 | 325 | else |
326 | 326 | { |
327 | 327 | // update the diff and the indices |
328 | 328 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::DELETED); |
329 | - $index1 --; |
|
329 | + $index1--; |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 |