GetSettingValue::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Anomaly\SettingsModule\Setting\Command;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
4
5
6
/**
7
 * Class GetSettingValue
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 */
13 View Code Duplication
class GetSettingValue
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...
14
{
15
16
    /**
17
     * The setting key.
18
     *
19
     * @var string
20
     */
21
    protected $key;
22
23
    /**
24
     * The default value.
25
     *
26
     * @var mixed
27
     */
28
    protected $default;
29
30
    /**
31
     * Create a new GetSettingValue instance.
32
     *
33
     * @param      $key
34
     * @param null $default
35
     */
36
    public function __construct($key, $default = null)
37
    {
38
        $this->key     = $key;
39
        $this->default = $default;
40
    }
41
42
    /**
43
     * Handle the command.
44
     *
45
     * @param  SettingRepositoryInterface $settings
46
     * @return mixed
47
     */
48
    public function handle(SettingRepositoryInterface $settings)
49
    {
50
        return $settings->value($this->key, $this->default);
51
    }
52
}
53