GetPreferenceValue   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 4 1
1
<?php namespace Anomaly\PreferencesModule\Preference\Command;
2
3
use Anomaly\PreferencesModule\Preference\Contract\PreferenceRepositoryInterface;
4
5
6
/**
7
 * Class GetPreferenceValue
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 */
13
class GetPreferenceValue
14
{
15
16
    /**
17
     * The preference 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 GetPreferenceValue 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  PreferenceRepositoryInterface $preferences
46
     * @return mixed
47
     */
48
    public function handle(PreferenceRepositoryInterface $preferences)
49
    {
50
        return $preferences->value($this->key, $this->default);
51
    }
52
}
53