Completed
Pull Request — master (#28)
by Vitaliy
04:27
created

Multiple   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 4
c 4
b 0
f 0
lcom 1
cbo 1
dl 0
loc 40
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setOptions() 0 4 1
A getOptions() 0 3 1
A setValue() 0 8 2
1
<?php
2
3
  namespace Fiv\Form\Element;
4
5
  /**
6
   *
7
   * @author  Ivan Shcherbak <[email protected]>
8
   * @package Fiv\Form\Html
9
   */
10
  class Multiple extends \Fiv\Form\Element\BaseElement {
11
12
    /**
13
     * @var array
14
     */
15
    protected $options = [];
16
17
18
    /**
19
     * @param array $values
20
     * @return $this
21
     */
22 6
    public function setOptions($values) {
23 6
      $this->options = $values;
24 6
      return $this;
25
    }
26
27
28
    /**
29
     * @return array
30
     */
31
    public function getOptions() {
32
      return $this->options;
33
    }
34
35
36
    /**
37
     * @param string $value
38
     * @return $this
39
     */
40 2
    public function setValue($value) {
41 2
      if (!isset($this->options[$value])) {
42
        reset($this->options);
43
        $value = key($this->options);
44
      }
45
46 2
      return parent::setValue($value);
47
    }
48
49
  }