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

Nip_Form_Element_MultiSelect   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 9
c 1
b 0
f 1
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 11 2
A isGroup() 0 3 1
A sanitizeDataFromRequest() 0 3 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