Last active
December 29, 2022 13:52
-
-
Save buismaarten/161be1b43601e0042a4e75ca1366a94a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use SebastianBergmann\Diff\Differ; | |
| use SebastianBergmann\Diff\Output\DiffOutputBuilderInterface; | |
| class MinimalDiffOutputBuilder implements DiffOutputBuilderInterface | |
| { | |
| /** | |
| * @param array $diff | |
| * @return string | |
| */ | |
| public function getDiff(array $diff): string | |
| { | |
| $result = ''; | |
| foreach ($diff as $entry) { | |
| $flag = ''; | |
| if ($entry[1] === Differ::ADDED) { | |
| $flag = '+'; | |
| } | |
| if ($entry[1] === Differ::REMOVED) { | |
| $flag = '-'; | |
| } | |
| $result .= sprintf(" %-1s %s\n", $flag, rtrim($entry[0])); | |
| } | |
| return rtrim($result, "\n"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment