ChoiceAwareElementMethods   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 45
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setOptions() 0 5 1
A getOptions() 0 4 1
A addOption() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of slick/form package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Form\Element;
11
12
/**
13
 * Choice Aware Element Methods trait
14
 *
15
 * @package Slick\Form\Element
16
 * @author  Filipe Silva <[email protected]>
17
 */
18
trait ChoiceAwareElementMethods
19
{
20
21
    /**
22
     * @var array List of options
23
     */
24
    protected $options = [];
25
26
    /**
27
     * Sets element options
28
     *
29
     * @param array $options
30
     *
31
     * @return self|$this|ChoiceAwareElementInterface
32
     */
33 34
    public function setOptions(array $options)
34
    {
35 34
        $this->options = $options;
36 34
        return $this;
37
    }
38
39
    /**
40
     * Get element options
41
     *
42
     * @return array
43
     */
44 6
    public function getOptions()
45
    {
46 6
        return $this->options;
47
    }
48
49
    /**
50
     * Add an option to the options list
51
     *
52
     * @param string $key
53
     * @param string $value
54
     *
55
     * @return self|$this|ChoiceAwareElementInterface
56
     */
57 2
    public function addOption($key, $value)
58
    {
59 2
        $this->options[$key] = $value;
60 2
        return $this;
61
    }
62
}