Completed
Push — master ( e85f0f...a6d11a )
by Ryan
02:21
created

GetPreferenceValue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 2
1
<?php namespace Anomaly\PreferencesModule\Preference\Command;
2
3
use Anomaly\PreferencesModule\Preference\Contract\PreferenceRepositoryInterface;
4
use Illuminate\Contracts\Bus\SelfHandling;
5
6
/**
7
 * Class GetPreferenceValue
8
 *
9
 * @link          http://anomaly.is/streams-platform
10
 * @author        AnomalyLabs, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 * @package       Anomaly\PreferencesModule\Preference\Command
13
 */
14
class GetPreferenceValue implements SelfHandling
15
{
16
17
    /**
18
     * The preference 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 GetPreferenceValue 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 PreferenceRepositoryInterface $preferences
47
     * @return mixed
48
     */
49
    public function handle(PreferenceRepositoryInterface $preferences)
50
    {
51
        return $preferences->value($this->key, $this->default);
52
    }
53
}
54