GetSettingValueFieldType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 35
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 8 2
1
<?php namespace Anomaly\SettingsModule\Setting\Command;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
4
5
6
/**
7
 * Class GetSettingValueFieldType
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 */
13
class GetSettingValueFieldType
14
{
15
16
    /**
17
     * The setting key.
18
     *
19
     * @var string
20
     */
21
    protected $key;
22
23
    /**
24
     * Create a new GetSettingValueFieldType instance.
25
     *
26
     * @param   $key
27
     */
28
    public function __construct($key)
29
    {
30
        $this->key = $key;
31
    }
32
33
    /**
34
     * Handle the command.
35
     *
36
     * @param  SettingRepositoryInterface                               $settings
37
     * @return \Anomaly\Streams\Platform\Addon\FieldType\FieldType|null
38
     */
39
    public function handle(SettingRepositoryInterface $settings)
40
    {
41
        if (!$setting = $settings->get($this->key)) {
42
            return null;
43
        }
44
45
        return $setting->getFieldType('value');
46
    }
47
}
48