ModifyValue   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
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 46
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 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\Foundation\Bus\DispatchesJobs;
7
8
/**
9
 * Class ModifyValue
10
 *
11
 * @link          http://pyrocms.com/
12
 * @author        PyroCMS, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 */
15
class ModifyValue
16
{
17
18
    use DispatchesJobs;
19
20
    /**
21
     * The setting value.
22
     *
23
     * @var mixed
24
     */
25
    protected $value;
26
27
    /**
28
     * The setting instance.
29
     *
30
     * @var SettingInterface
31
     */
32
    protected $setting;
33
34
    /**
35
     * Create a new ModifyValue instance.
36
     *
37
     * @param SettingInterface $setting
38
     * @param                  $value
39
     */
40
    function __construct(SettingInterface $setting, $value)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
41
    {
42
        $this->value   = $value;
43
        $this->setting = $setting;
44
    }
45
46
    /**
47
     * Handle the command.
48
     *
49
     * @return mixed
50
     */
51
    public function handle()
52
    {
53
        /* @var FieldType $type */
54
        if ($type = $this->dispatch(new GetValueFieldType($this->setting))) {
55
            return $type->getModifier()->modify($this->value);
56
        }
57
58
        return $this->value;
59
    }
60
}
61