Completed
Push — master ( 3c5c0f...ec5ff6 )
by Laurent
01:40
created

Select   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 63
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getValueOptions() 0 4 1
A setValueOptions() 0 5 1
A addValueOption() 0 5 1
A setValue() 0 8 3
1
<?php
2
/**
3
 *
4
 */
5
6
namespace flightlog\form;
7
8
/**
9
 * @author Laurent De Coninck <[email protected]>
10
 */
11
class Select extends BaseInput
12
{
13
14
    /**
15
     * @var array
16
     */
17
    private $valueOptions;
18
19
    /**
20
     * @param string $name
21
     * @param array  $options
22
     */
23
    public function __construct($name, $options = [])
24
    {
25
        parent::__construct($name, FormElementInterface::TYPE_SELECT, $options);
26
        $this->valueOptions = [];
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function getValueOptions()
33
    {
34
        return $this->valueOptions;
35
    }
36
37
    /**
38
     * @param array $valueOptions
39
     *
40
     * @return Select
41
     */
42
    public function setValueOptions($valueOptions)
43
    {
44
        $this->valueOptions = $valueOptions;
45
        return $this;
46
    }
47
48
    /**
49
     * @param mixed $key
50
     * @param mixed $value
51
     *
52
     * @return $this
53
     */
54
    public function addValueOption($key, $value)
55
    {
56
        $this->valueOptions[$key] = $value;
57
        return $this;
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63
    public function setValue($value)
64
    {
65
        parent::setValue($value);
66
67
        if (!isset($this->valueOptions[$value])) {
68
            $this->valueOptions[$value] = empty($value) ? ' ' : $value;
69
        }
70
    }
71
72
73
}