Completed
Pull Request — master (#107)
by
unknown
04:23
created

SelectFilterConfig::isMultipleMode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Nayjest\Grids;
3
4
class SelectFilterConfig extends FilterConfig
5
{
6
    protected $template = '*.select';
7
8
    protected $options = [];
9
10
    protected $is_submitted_on_change = false;
11
12
    protected $size = null;
13
14
    protected $multipleMode = false;
15
16
    /**
17
     * Returns option items of html select tag.
18
     *
19
     * @return array
20
     */
21
    public function getOptions()
22
    {
23
        return $this->options;
24
    }
25
26
    /**
27
     * Sets option items for html select tag.
28
     *
29
     * @param array $options
30
     * @return $this
31
     */
32
    public function setOptions(array $options)
33
    {
34
        $this->options = $options;
35
        return $this;
36
    }
37
38
    /**
39
     * Returns true if form must be submitted immediately
40
     * when filter value selected.
41
     *
42
     * @return bool
43
     */
44
    public function isSubmittedOnChange()
45
    {
46
        return $this->is_submitted_on_change;
47
    }
48
49
    /**
50
     * Allows to submit form immediately when filter value selected.
51
     *
52
     * @param bool $isSubmittedOnChange
53
     * @return $this
54
     */
55
    public function setSubmittedOnChange($isSubmittedOnChange)
56
    {
57
        $this->is_submitted_on_change = $isSubmittedOnChange;
58
        return $this;
59
    }
60
61
    /**
62
     * Sets the size of the select element.
63
     *
64
     * @param int $size
65
     *
66
     * @return $this
67
     */
68
    public function setSize($size)
69
    {
70
        $this->size = $size;
71
72
        return $this;
73
    }
74
75
    /**
76
     * Returns the size of the select element.
77
     *
78
     * @return int
79
     */
80
    public function getSize()
81
    {
82
        return $this->size;
83
    }
84
85
    /**
86
     * Enabled multiple mode.
87
     * This will switch the selected operator to IN, as any other operator does not work with multiple selections.
88
     *
89
     * @param $multipleMode
90
     *
91
     * @return $this
92
     */
93
    public function setMultipleMode($multipleMode)
94
    {
95
        $this->multipleMode = $multipleMode;
96
97
        if ($multipleMode) {
98
            $this->operator = FilterConfig::OPERATOR_IN;
99
        }
100
101
        return $this;
102
    }
103
104
    /**
105
     * Returns if the multiple mode is enabled
106
     *
107
     * @return bool
108
     */
109
    public function isMultipleMode()
110
    {
111
        return $this->multipleMode;
112
    }
113
}
114
115