Wanted: PHP Implementation of Unified Diff

For PHPUnit I need a PHP function (written in PHP, an extension would not solve the problem) that

  • takes two strings as its input and
  • returns a string with the differences between the two string in the same format as GNU diff would return for diff -u for two files that contain the respective strings. Currently I rely on GNU diff being installed on the system that PHPUnit runs on. This thread on the PHPUnit mailinglist shows that this poses a problem. I know that there is a Text_Diff package in PEAR but it does way more than I need.