ModifyValue::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 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
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