GetValuePresenter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

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