@@ 14-53 (lines=40) @@ | ||
11 | * @author Ryan Thompson <[email protected]> |
|
12 | * @package Anomaly\SettingsModule\Setting\Plugin\Command |
|
13 | */ |
|
14 | class GetSetting implements SelfHandling |
|
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 |
@@ 14-53 (lines=40) @@ | ||
11 | * @author Ryan Thompson <[email protected]> |
|
12 | * @package Anomaly\SettingsModule\Setting\Plugin\Command |
|
13 | */ |
|
14 | class GetSettingValue implements SelfHandling |
|
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 GetSettingValue 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->value($this->key, $this->default); |
|
52 | } |
|
53 | } |
|
54 |