GetValuePresenter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 9 2
1
<?php namespace Anomaly\SettingsModule\Setting\Command;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingInterface;
4
use Anomaly\Streams\Platform\Addon\FieldType\FieldType;
5
use Anomaly\Streams\Platform\Addon\FieldType\FieldTypeCollection;
6
use Illuminate\Contracts\Config\Repository;
7
use Illuminate\Foundation\Bus\DispatchesJobs;
8
9
/**
10
 * Class GetValuePresenter
11
 *
12
 * @link          http://pyrocms.com/
13
 * @author        PyroCMS, Inc. <[email protected]>
14
 * @author        Ryan Thompson <[email protected]>
15
 */
16
class GetValuePresenter
17
{
18
19
    use DispatchesJobs;
20
21
    /**
22
     * The setting instance.
23
     *
24
     * @var SettingInterface
25
     */
26
    protected $setting;
27
28
    /**
29
     * Create a new GetValuePresenter instance.
30
     *
31
     * @param SettingInterface $setting
32
     */
33
    public function __construct(SettingInterface $setting)
34
    {
35
        $this->setting = $setting;
36
    }
37
38
    /**
39
     * Handle the command.
40
     *
41
     * @return \Anomaly\Streams\Platform\Addon\FieldType\FieldTypePresenter|mixed|object
42
     */
43
    public function handle()
44
    {
45
        /* @var FieldType $type */
46
        if ($type = $this->dispatch(new GetValueFieldType($this->setting))) {
47
            return $type->getPresenter();
48
        }
49
50
        return array_get($this->setting->getAttributes(), 'value');
51
    }
52
}
53