StringOptionsAwareTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 34.29 %

Importance

Changes 0
Metric Value
dl 12
loc 35
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setStringOptions() 0 7 1
A getConfigInstance() 11 11 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 Fwolf\Config;
4
5
/**
6
 * Trait for Config aware class also accept StringOptions
7
 *
8
 * @copyright   Copyright 2015-2017 Fwolf
9
 * @license     https://opensource.org/licenses/MIT MIT
10
 */
11
trait StringOptionsAwareTrait
12
{
13
    use ConfigAwareTrait;
14
15
16
    /**
17
     * @return StringOptions
18
     */
19 View Code Duplication
    protected function getConfigInstance()
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...
20
    {
21
        if (is_null($this->configInstance)) {
22
            $config = new StringOptions();
23
24
            $config->setMultiple($this->getDefaultConfigs());
25
26
            $this->configInstance = $config;
27
        }
28
29
        return $this->configInstance;
30
    }
31
32
33
    /**
34
     * Set options/config with string
35
     *
36
     * @param   string $optionString
37
     * @return  $this
38
     */
39
    public function setStringOptions($optionString)
40
    {
41
        $config = $this->getConfigInstance();
42
43
        $config->setStringOptions($optionString);
44
45
        return $this;
46
    }
47
}
48