Completed
Push — master ( 7e918b...fc4c54 )
by Matthieu
10s
created

PropertyInjection::__toString()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 4
Code Lines 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
rs 10
1
<?php
2
3
namespace DI\Definition\ObjectDefinition;
4
5
/**
6
 * Describe an injection in a class property.
7
 *
8
 * @author Matthieu Napoli <[email protected]>
9
 */
10
class PropertyInjection
11
{
12
    /**
13
     * Property name.
14
     * @var string
15
     */
16
    private $propertyName;
17
18
    /**
19
     * Value that should be injected in the property.
20
     * @var mixed
21
     */
22
    private $value;
23
24
    /**
25
     * Use for injecting in properties of parent classes: the class name
26
     * must be the name of the parent class because private properties
27
     * can be attached to the parent classes, not the one we are resolving.
28
     * @var string|null
29
     */
30
    private $className;
31
32
    /**
33
     * @param string $propertyName Property name
34
     * @param mixed $value Value that should be injected in the property
35
     */
36
    public function __construct(string $propertyName, $value, string $className = null)
37
    {
38
        $this->propertyName = $propertyName;
39
        $this->value = $value;
40
        $this->className = $className;
41
    }
42
43
    public function getPropertyName() : string
44
    {
45
        return $this->propertyName;
46
    }
47
48
    /**
49
     * @return mixed Value that should be injected in the property
50
     */
51
    public function getValue()
52
    {
53
        return $this->value;
54
    }
55
56
    /**
57
     * @return string|null
58
     */
59
    public function getClassName()
60
    {
61
        return $this->className;
62
    }
63
64
    public function __toString()
65
    {
66
        return sprintf('property(%s)', $this->propertyName);
67
    }
68
}
69