summaryrefslogtreecommitdiffstats
path: root/library/Toplevelview/Monitoring/Options.php
blob: 75f739f1273c4ca455237830d0ab424379262be5 (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
<?php
/* Copyright (C) 2019 Icinga Development Team <info@icinga.com> */

namespace Icinga\Module\Toplevelview\Monitoring;

trait Options
{
    protected $options = [];

    public function getOption($key)
    {
        if (array_key_exists($key, $this->options)) {
            return $this->options[$key];
        }

        return null;
    }

    public function setOptions($options, $flush = false)
    {
        if ($flush) {
            $this->options = [];
        }

        if (! empty($options)) {
            foreach ($options as $k => $v) {
                $this->options[$k] = $v;
            }
        }

        return $this;
    }
}