DiffConsoleFormatter - allow simpler diffs

This commit is contained in:
Tomas Votruba 2018-04-09 14:48:00 +02:00
parent 3e74964fde
commit 7e14d1208e
2 changed files with 14 additions and 2 deletions

View File

@ -29,9 +29,19 @@ final class DiffConsoleFormatter
}
public function format(string $diff): string
{
return $this->formatWithTemplate($diff, $this->template);
}
public function bareFormat(string $diff): string
{
return $this->formatWithTemplate($diff, PHP_EOL .'%s' . PHP_EOL);
}
private function formatWithTemplate(string $diff, string $template): string
{
return sprintf(
$this->template,
$template,
implode(PHP_EOL, array_map(function ($string) {
// make "+" lines green
// make "-" lines red

View File

@ -50,7 +50,9 @@ final class DifferAndFormatter
}
$diff = $this->bareDiffer->diff($old, $new);
// impossible to configure - removed manually
$diff = substr($diff, strlen("@@ @@ "));
return $this->diffConsoleFormatter->format($diff);
return $this->diffConsoleFormatter->bareFormat($diff);
}
}