Test Setup Failed
Push — master ( 6d6991...a81a2e )
by Gabriel
02:14
created

HasOptionsTrait::setOption()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Nip\Form\Elements\Traits;
4
5
/**
6
 * Trait HasOptionsTrait
7
 * @package Nip\Form\Elements\Traits
8
 */
9
trait HasOptionsTrait
10
{
11
    protected $_options;
12
13
    /**
14
     * @param $key
15
     * @param $value
16
     * @return $this
17
     */
18
    public function setOption($key, $value)
19
    {
20
        $key = (string)$key;
21
        $this->_options[$key] = $value;
22
23
        return $this;
24
    }
25
26
    /**
27
     * @param string $key
28
     * @return null
29
     */
30 View Code Duplication
    public function getOption($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $key = (string)$key;
33
        if (!isset($this->_options[$key])) {
34
            return null;
35
        }
36
37
        return $this->_options[$key];
38
    }
39
}
40