ConstParameterDefinition::toPhpCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace TheCodingMachine\Yaco\Definition;
4
5
/**
6
 * This class represents a constant parameter (a "define" or a const in a class).
7
 */
8
class ConstParameterDefinition 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 name of the constant. If it is a class constant, please pass the FQDN. For instance: "My\Class::CONSTANT".
19
     *
20
     * @var string
21
     */
22
    private $const;
23
24
    /**
25
     * Constructs an instance definition.
26
     *
27
     * @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)
28
     * @param string      $const      The name of the constant. If it is a class constant, please pass the FQDN. For instance: "My\Class::CONSTANT"
29
     */
30
    public function __construct($identifier, $const)
31
    {
32
        $this->identifier = $identifier;
33
        $this->const = $const;
34
    }
35
36
    /**
37
     * Returns the identifier of the instance.
38
     *
39
     * @return string
40
     */
41
    public function getIdentifier()
42
    {
43
        return $this->identifier;
44
    }
45
46
    /**
47
     * The name of the constant. If it is a class constant, please pass the FQDN. For instance: "My\Class::CONSTANT".
48
     *
49
     * @return mixed
50
     */
51
    public function getConst()
52
    {
53
        return $this->const;
54
    }
55
56
    /**
57
     * Returns an InlineEntryInterface object representing the PHP code necessary to generate
58
     * the container entry.
59
     *
60
     * @param string $containerVariable The name of the variable that allows access to the container instance. For instance: "$container", or "$this->container"
61
     * @param array  $usedVariables     An array of variables that are already used and that should not be used when generating this code.
62
     *
63
     * @return InlineEntryInterface
64
     */
65
    public function toPhpCode($containerVariable, array $usedVariables = array())
66
    {
67
        return new InlineEntry($this->const, null, $usedVariables, false);
68
    }
69
}
70