Passed
Push — master ( ab2dc9...db3995 )
by Gabriel
14:15 queued 10s
created

Nip_Form_Element_MultiSelect::setValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 11
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
class Nip_Form_Element_MultiSelect extends Nip_Form_Element_Select
4
{
5
    protected $_type = 'multiSelect';
6
7
8
    /**
9
     * @param $request
10
     * @return string
11
     */
12
    protected function sanitizeDataFromRequest($request)
13
    {
14
        return $request;
15
    }
16
17
    /**
18
     * @inheritDoc
19
     */
20
    public function setValue($value)
21
    {
22
        if (!is_array($value)) {
23
            return false;
24
        }
25
26
        $this->setAttrib('value', array_filter($value, function ($value) {
27
            return in_array($value, $this->_values);
28
        }));
29
30
        return $this;
31
    }
32
33
    /**
34
     * @return bool
35
     */
36
    public function isGroup()
37
    {
38
        return true;
39
    }
40
}
41