Completed
Push — feature/update_flight ( 5eb300...a7cb77 )
by Laurent
01:44
created

Select::addValueOption()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
        $this->valueOptions[$key] = $value;
56
        return $this;
57
    }
58
59
    /**
60
     * @inheritDoc
61
     */
62
    public function setValue($value)
63
    {
64
        parent::setValue($value);
65
66
        if(!isset($this->valueOptions[$value])){
67
            $this->valueOptions[$value] = $value;
68
        }
69
    }
70
71
72
}