ParameterDefinition   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 4
c 4
b 0
f 0
lcom 1
cbo 1
dl 0
loc 63
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getIdentifier() 0 4 1
A getValue() 0 4 1
A toPhpCode() 0 4 1
1
<?php
2
3
namespace TheCodingMachine\Yaco\Definition;
4
5
/**
6
 * This class represents a parameter.
7
 */
8
class ParameterDefinition implements DumpableInterface
9
{
10
    /**
11
     * The identifier of the instance in the container.
12
     *
13
     * @var string
14
     */
15
    private $identifier;
16
17
    /**
18
     * The value of the parameter.
19
     * It is expected to be a scalar or an array (or more generally anything that can be `var_export`ed).
20
     *
21
     * @var mixed
22
     */
23
    private $value;
24
25
    /**
26
     * Constructs an instance definition.
27
     *
28
     * @param string|null $identifier The identifier of the entry in the container. Can be null if the entry is anonymous (declared inline in other instances)
29
     * @param string      $value      The value of the parameter. It is expected to be a scalar or an array (or more generally anything that can be `var_export`ed)
30
     */
31
    public function __construct($identifier, $value)
32
    {
33
        $this->identifier = $identifier;
34
        $this->value = $value;
35
    }
36
37
    /**
38
     * Returns the identifier of the instance.
39
     *
40
     * @return string
41
     */
42
    public function getIdentifier()
43
    {
44
        return $this->identifier;
45
    }
46
47
    /**
48
     * Returns the value of the parameter.
49
     *
50
     * @return mixed
51
     */
52
    public function getValue()
53
    {
54
        return $this->value;
55
    }
56
57
    /**
58
     * Returns an InlineEntryInterface object representing the PHP code necessary to generate
59
     * the container entry.
60
     *
61
     * @param string $containerVariable The name of the variable that allows access to the container instance. For instance: "$container", or "$this->container"
62
     * @param array  $usedVariables     An array of variables that are already used and that should not be used when generating this code.
63
     *
64
     * @return InlineEntryInterface
65
     */
66
    public function toPhpCode($containerVariable, array $usedVariables = array())
67
    {
68
        return ValueUtils::dumpValue($this->value, $containerVariable, $usedVariables);
69
    }
70
}
71