Skip to content

Commit f4f8b25

Browse files
committed
Tidy codes
Signed-off-by: Jack Cherng <[email protected]>
1 parent 273d1b4 commit f4f8b25

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

src/Renderer/Html/Combined.php

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ protected function renderTableBlockDelete(array $block): string
182182
*/
183183
protected function renderTableBlockReplace(array $block): string
184184
{
185+
if ($this->options['detailLevel'] === 'none') {
186+
return $this->renderTableBlockDelete($block) . $this->renderTableBlockInsert($block);
187+
}
188+
185189
$html = '';
186190

187191
$oldLines = $block['old']['lines'];
@@ -197,12 +201,6 @@ protected function renderTableBlockReplace(array $block): string
197201
$oldLinesCount = $newLinesCount = 1;
198202
}
199203

200-
// fix for "detailLevel" is "none"
201-
if ($this->options['detailLevel'] === 'none') {
202-
$this->fixLinesForNoClosure($oldLines, RendererConstant::HTML_CLOSURES_DEL);
203-
$this->fixLinesForNoClosure($newLines, RendererConstant::HTML_CLOSURES_INS);
204-
}
205-
206204
// now $oldLines must has the same line counts with $newlines
207205
for ($no = 0; $no < $newLinesCount; ++$no) {
208206
$mergedLine = $this->mergeReplaceLines($oldLines[$no], $newLines[$no]);
@@ -215,9 +213,7 @@ protected function renderTableBlockReplace(array $block): string
215213

216214
$html .=
217215
'<tr data-type="!">' .
218-
'<td class="rep">' .
219-
$mergedLine .
220-
'</td>' .
216+
'<td class="rep">' . $mergedLine . '</td>' .
221217
'</tr>';
222218
}
223219

@@ -396,23 +392,6 @@ protected function markReplaceBlockDiff(array $oldBlock, array $newBlock): array
396392
];
397393
}
398394

399-
/**
400-
* Wrap the whole line with closures if it does not have one.
401-
*
402-
* @param string[] $lines the lines
403-
* @param string[] $closures the closures
404-
*/
405-
protected function fixLinesForNoClosure(array &$lines, array $closures): void
406-
{
407-
foreach ($lines as &$line) {
408-
// there is no closure in a "replace"-type line
409-
// this means that the entire line changes
410-
if (false === \strpos($line, $closures[0])) {
411-
$line = "{$closures[0]}{$line}{$closures[1]}";
412-
}
413-
}
414-
}
415-
416395
/**
417396
* Determine whether the "replace"-type lines are merge-able or not.
418397
*

0 commit comments

Comments
 (0)