ModifyValue   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 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\Foundation\Bus\DispatchesJobs;
6
7
/**
8
 * Class ModifyValue
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 */
14
class ModifyValue
15
{
16
17
    use DispatchesJobs;
18
19
    /**
20
     * The preference value.
21
     *
22
     * @var mixed
23
     */
24
    protected $value;
25
26
    /**
27
     * The preference instance.
28
     *
29
     * @var PreferenceInterface
30
     */
31
    protected $preference;
32
33
    /**
34
     * Create a new ModifyValue instance.
35
     *
36
     * @param PreferenceInterface $preference
37
     * @param                     $value
38
     */
39
    function __construct(PreferenceInterface $preference, $value)
0 ignored issues
show
Best Practice introduced by Ryan Thompson
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...
40
    {
41
        $this->value      = $value;
42
        $this->preference = $preference;
43
    }
44
45
    /**
46
     * Handle the command.
47
     *
48
     * @return mixed
49
     */
50
    public function handle()
51
    {
52
        /* @var FieldType $type */
53
        if ($type = $this->dispatch(new GetValueFieldType($this->preference))) {
54
            return $type->getModifier()->modify($this->value);
55
        }
56
57
        return $this->value;
58
    }
59
}
60