Reference   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTarget() 0 4 1
A toPhpCode() 0 4 1
1
<?php
2
3
namespace TheCodingMachine\Yaco\Definition;
4
5
/**
6
 * A reference to a service.
7
 */
8
class Reference implements ReferenceInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    private $target;
14
15
    /**
16
     * Constructs a Reference object targeting the $target entry.
17
     *
18
     * @param string $target
19
     */
20
    public function __construct($target)
21
    {
22
        $this->target = $target;
23
    }
24
25
    /**
26
     * Returns the identifier for the object in the container.
27
     *
28
     * @return string
29
     */
30
    public function getTarget()
31
    {
32
        return $this->target;
33
    }
34
35
    /**
36
     * Returns an InlineEntryInterface object representing the PHP code necessary to generate
37
     * the container entry.
38
     *
39
     * @param string $containerVariable The name of the variable that allows access to the container instance. For instance: "$container", or "$this->container"
40
     * @param array  $usedVariables     An array of variables that are already used and that should not be used when generating this code.
41
     *
42
     * @return InlineEntryInterface
43
     */
44
    public function toPhpCode($containerVariable, array $usedVariables = array())
45
    {
46
        return new InlineEntry(sprintf('%s->get(%s)', $containerVariable, var_export($this->getTarget(), true)), null, $usedVariables);
47
    }
48
}
49