‪TYPO3CMS  ‪main
DiffUtility.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use cogpowered\FineDiff\Diff;
21 use cogpowered\FineDiff\Granularity\Character;
22 use cogpowered\FineDiff\Granularity\Word;
23 
28 {
32  public bool ‪$stripTags = true;
33 
37  public function ‪makeDiffDisplay(string $str1, string $str2, ‪DiffGranularity $granularity = DiffGranularity::WORD): string
38  {
39  if ($this->stripTags) {
40  $str1 = strip_tags($str1);
41  $str2 = strip_tags($str2);
42  }
43  $granularity = $granularity === DiffGranularity::WORD ? new Word() : new Character();
44  $diff = new Diff($granularity);
45  return $diff->render($str1, $str2);
46  }
47 }
‪TYPO3\CMS\Core\Utility\DiffUtility
Definition: DiffUtility.php:28
‪TYPO3\CMS\Core\Utility\DiffUtility\$stripTags
‪bool $stripTags
Definition: DiffUtility.php:32
‪TYPO3\CMS\Core\Utility
Definition: ArrayUtility.php:18
‪TYPO3\CMS\Core\Utility\DiffUtility\makeDiffDisplay
‪makeDiffDisplay(string $str1, string $str2, DiffGranularity $granularity=DiffGranularity::WORD)
Definition: DiffUtility.php:37
‪TYPO3\CMS\Core\Utility\DiffGranularity
‪DiffGranularity
Definition: DiffGranularity.php:21