blob: 133cfb74b9effe017ee84e3b6308a9124c44963e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php
namespace Icinga\Module\Businessprocess\Storage;
use ipl\Html\ValidHtml;
use Jfcherng\Diff\Differ;
use Jfcherng\Diff\Factory\RendererFactory;
class ConfigDiff implements ValidHtml
{
protected $a;
protected $b;
protected $diff;
protected $opcodes;
protected function __construct($a, $b)
{
if (empty($a)) {
$this->a = array();
} else {
$this->a = explode("\n", (string) $a);
}
if (empty($b)) {
$this->b = array();
} else {
$this->b = explode("\n", (string) $b);
}
$options = array(
'context' => 5,
// 'ignoreWhitespace' => true,
// 'ignoreCase' => true,
);
$this->diff = new Differ($this->a, $this->b, $options);
}
/**
* @return string
*/
public function render()
{
return $this->renderHtmlSideBySide();
}
public function renderHtmlSideBySide()
{
$renderer = RendererFactory::make('SideBySide');
return $renderer->render($this->diff);
}
public function renderHtmlInline()
{
$renderer = RendererFactory::make('Inline');
return $renderer->render($this->diff);
}
public function renderTextContext()
{
$renderer = RendererFactory::make('Context');
return $renderer->render($this->diff);
}
public function renderTextUnified()
{
$renderer = RendererFactory::make('Unified');
return $renderer->render($this->diff);
}
public static function create($a, $b)
{
$diff = new static($a, $b);
return $diff;
}
}
|