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\ConfigurationModule\Configuration\Command;
2
3
use Anomaly\ConfigurationModule\Configuration\Contract\ConfigurationInterface;
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 configuration value.
21
     *
22
     * @var mixed
23
     */
24
    protected $value;
25
26
    /**
27
     * The configuration instance.
28
     *
29
     * @var ConfigurationInterface
30
     */
31
    protected $configuration;
32
33
    /**
34
     * Create a new ModifyValue instance.
35
     *
36
     * @param ConfigurationInterface $configuration
37
     * @param                        $value
38
     */
39
    function __construct(ConfigurationInterface $configuration, $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->configuration = $configuration;
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->configuration))) {
54
            return $type->getModifier()->modify($this->value);
55
        }
56
57
        return $this->value;
58
    }
59
}
60