summaryrefslogtreecommitdiffstats
path: root/library/Director/ConfigDiff.php
blob: acf5f7b24d2bf711b4fa7f036352de2e568c9a06 (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
<?php

namespace Icinga\Module\Director;

use gipfl\Diff\HtmlRenderer\InlineDiff;
use gipfl\Diff\HtmlRenderer\SideBySideDiff;
use gipfl\Diff\PhpDiff;
use ipl\Html\ValidHtml;
use InvalidArgumentException;

/**
 * @deprecated will be removed with v1.9 - please use gipfl\Diff
 */
class ConfigDiff implements ValidHtml
{
    protected $renderClass;

    /** @var PhpDiff */
    protected $phpDiff;

    public function __construct($a, $b)
    {
        $this->phpDiff = new PhpDiff($a, $b);
    }

    public function render()
    {
        $class = $this->renderClass;
        return (new $class($this->phpDiff))->render();
    }

    public function setHtmlRenderer($name)
    {
        switch ($name) {
            case 'SideBySide':
                $this->renderClass = SideBySideDiff::class;
                break;
            case 'Inline':
                $this->renderClass = InlineDiff::class;
                break;
            default:
                throw new InvalidArgumentException("There is no known '$name' renderer");
        }

        return $this;
    }
}