Completed
Push — master ( f3882c...729f05 )
by Ryan
02:47
created

GetSetting   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 1
cbo 1
dl 40
loc 40
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A handle() 4 4 1

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 namespace Anomaly\SettingsModule\Setting\Command;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
4
use Illuminate\Contracts\Bus\SelfHandling;
5
6
/**
7
 * Class GetSetting
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 * @package       Anomaly\SettingsModule\Setting\Plugin\Command
13
 */
14 View Code Duplication
class GetSetting implements SelfHandling
0 ignored issues
show
Duplication introduced by
This class 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...
15
{
16
17
    /**
18
     * The setting key.
19
     *
20
     * @var string
21
     */
22
    protected $key;
23
24
    /**
25
     * The default value.
26
     *
27
     * @var mixed
28
     */
29
    protected $default;
30
31
    /**
32
     * Create a new GetSetting instance.
33
     *
34
     * @param      $key
35
     * @param null $default
36
     */
37
    public function __construct($key, $default = null)
38
    {
39
        $this->key     = $key;
40
        $this->default = $default;
41
    }
42
43
    /**
44
     * Handle the command.
45
     *
46
     * @param SettingRepositoryInterface $settings
47
     * @return mixed
48
     */
49
    public function handle(SettingRepositoryInterface $settings)
50
    {
51
        return $settings->get($this->key, $this->default);
52
    }
53
}
54