ContainerDefinition::getIdentifier()   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 0
1
<?php
2
3
4
namespace TheCodingMachine\Yaco\ServiceProvider;
5
6
7
use TheCodingMachine\Yaco\Definition\DumpableInterface;
8
use TheCodingMachine\Yaco\Definition\InlineEntry;
9
use TheCodingMachine\Yaco\Definition\InlineEntryInterface;
10
11
/**
12
 * A definition that points to "$this" container.
13
 */
14
class ContainerDefinition implements DumpableInterface
15
{
16
    /**
17
     * The identifier of the instance in the container.
18
     *
19
     * @var string|null
20
     */
21
    private $identifier;
22
23
    /**
24
     * @param null|string $identifier
25
     */
26
    public function __construct($identifier = null)
27
    {
28
        $this->identifier = $identifier;
29
    }
30
31
    /**
32
     * Returns the identifier for this object in the container.
33
     * If null, classes consuming this definition should assume the definition must be inlined.
34
     *
35
     * @return string|null
36
     */
37
    public function getIdentifier()
38
    {
39
        return $this->identifier;
40
    }
41
42
    /**
43
     * Returns an InlineEntryInterface object representing the PHP code necessary to generate
44
     * the container entry.
45
     *
46
     * @param string $containerVariable The name of the variable that allows access to the container instance. For instance: "$container", or "$this->container"
47
     * @param array $usedVariables An array of variables that are already used and that should not be used when generating this code.
48
     *
49
     * @return InlineEntryInterface
50
     */
51
    public function toPhpCode($containerVariable, array $usedVariables = array())
52
    {
53
        return new InlineEntry($containerVariable, null, $usedVariables);
54
    }
55
}
56