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

HasOptionsTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 29.03 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setOption() 0 7 1
A getOption() 9 9 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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