Passed
Push — master ( fbcfc1...811dca )
by Jan
04:33
created

TreeViewNodeState::jsonSerialize()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
c 0
b 0
f 0
nc 8
nop 0
dl 0
loc 16
rs 10
1
<?php
2
/**
3
 * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
4
 *
5
 * Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
20
 */
21
22
namespace App\Helpers\Trees;
23
24
class TreeViewNodeState implements \JsonSerializable
25
{
26
    /** @var bool|null */
27
    protected $checked = null;
28
29
    /** @var bool|null */
30
    protected $disabled = null;
31
32
    /** @var bool|null */
33
    protected $expanded = null;
34
35
    /** @var bool|null */
36
    protected $selected = null;
37
38
    /**
39
     * @return bool|null
40
     */
41
    public function getDisabled(): ?bool
42
    {
43
        return $this->disabled;
44
    }
45
46
    public function setDisabled(?bool $disabled): void
47
    {
48
        $this->disabled = $disabled;
49
    }
50
51
    /**
52
     * @return bool|null
53
     */
54
    public function getExpanded(): ?bool
55
    {
56
        return $this->expanded;
57
    }
58
59
    public function setExpanded(?bool $expanded): void
60
    {
61
        $this->expanded = $expanded;
62
    }
63
64
    /**
65
     * @return bool|null
66
     */
67
    public function getSelected(): ?bool
68
    {
69
        return $this->selected;
70
    }
71
72
    public function setSelected(?bool $selected): void
73
    {
74
        $this->selected = $selected;
75
    }
76
77
    /**
78
     * @inheritDoc
79
     */
80
    public function jsonSerialize()
81
    {
82
        $ret = [];
83
        if ($this->selected !== null) {
84
            $ret['selected'] = $this->selected;
85
        }
86
87
        if($this->disabled !== null) {
88
            $ret['disabled'] = $this->disabled;
89
        }
90
91
        if($this->expanded !== null) {
92
            $ret['expanded'] = $this->expanded;
93
        }
94
95
        return $ret;
96
    }
97
}
98