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

namespace Icinga\Module\Director\CustomVariable;

use Icinga\Exception\ProgrammingError;

class CustomVariableNull extends CustomVariable
{
    public function equals(CustomVariable $var)
    {
        return $var instanceof CustomVariableNull;
    }

    public function getValue()
    {
        return null;
    }

    public function getDbValue()
    {
        return json_encode($this->getValue());
    }

    public function getDbFormat()
    {
        return 'json';
    }

    public function setValue($value)
    {
        if (! is_null($value)) {
            throw new ProgrammingError(
                'Null can only be null, got %s',
                var_export($value, 1)
            );
        }

        $this->deleted = false;

        return $this;
    }

    public function toConfigString($renderExpressions = false)
    {
        return 'null';
    }

    public function toLegacyConfigString()
    {
        return $this->toConfigString();
    }
}