mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-20 08:27:21 +08:00
gii WIP
This commit is contained in:
31
framework/yii/gii/components/TextDiff.php
Normal file
31
framework/yii/gii/components/TextDiff.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\gii\components;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class TextDiff
|
||||
{
|
||||
public static function compare($lines1, $lines2)
|
||||
{
|
||||
Yii::setAlias('@Horde', '@yii/gii/lib/Horde');
|
||||
if (is_string($lines1)) {
|
||||
$lines1 = explode("\n", $lines1);
|
||||
}
|
||||
if (is_string($lines2)) {
|
||||
$lines2 = explode("\n", $lines2);
|
||||
}
|
||||
$diff = new \Horde_Text_Diff('auto', array($lines1, $lines2));
|
||||
$renderer = new \Horde_Text_Diff_Renderer_Inline();
|
||||
return $renderer->render($diff);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user