1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
/** |
3
|
|
|
* Created by Ruslan Molodyko. |
4
|
|
|
* Date: 07.09.2016 |
5
|
|
|
* Time: 5:53 |
6
|
|
|
*/ |
7
|
|
|
namespace samsonframework\container\definition; |
8
|
|
|
|
9
|
|
|
use samsonframework\container\definition\reference\ReferenceInterface; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class ParameterDefinition |
13
|
|
|
* |
14
|
|
|
* @author Ruslan Molodyko <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class ParameterDefinition extends AbstractPropertyDefinition implements ParameterBuilderInterface |
17
|
|
|
{ |
18
|
|
|
/** @var string Property name */ |
19
|
|
|
protected $parameterName; |
20
|
|
|
/** @var bool If optional parameter */ |
21
|
|
|
protected $isOptional; |
22
|
|
|
/** @var \ReflectionType Property typeHint from typeHint hint */ |
23
|
|
|
protected $typeHint; |
24
|
|
|
/** @var mixed Property value */ |
25
|
|
|
public $value; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Define argument |
29
|
|
|
* |
30
|
|
|
* @param ReferenceInterface $dependency |
31
|
|
|
* @return ParameterBuilderInterface |
32
|
|
|
*/ |
33
|
12 |
|
public function defineDependency(ReferenceInterface $dependency): ParameterBuilderInterface |
34
|
|
|
{ |
35
|
12 |
|
$this->dependency = $dependency; |
36
|
|
|
|
37
|
12 |
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return string |
42
|
|
|
*/ |
43
|
1 |
|
public function getParameterName(): string |
44
|
|
|
{ |
45
|
1 |
|
return $this->parameterName; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param string $parameterName |
50
|
|
|
* @return ParameterDefinition |
51
|
|
|
*/ |
52
|
13 |
|
public function setParameterName(string $parameterName): ParameterDefinition |
53
|
|
|
{ |
54
|
13 |
|
$this->parameterName = $parameterName; |
55
|
|
|
|
56
|
13 |
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return mixed |
61
|
|
|
*/ |
62
|
1 |
|
public function isOptional() |
63
|
|
|
{ |
64
|
1 |
|
return $this->isOptional; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param mixed $isOptional |
69
|
|
|
* @return ParameterDefinition |
70
|
|
|
*/ |
71
|
6 |
|
public function setIsOptional($isOptional) |
72
|
|
|
{ |
73
|
6 |
|
$this->isOptional = $isOptional; |
74
|
|
|
|
75
|
6 |
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return \ReflectionType |
80
|
|
|
*/ |
81
|
3 |
|
public function getTypeHint(): \ReflectionType |
82
|
|
|
{ |
83
|
3 |
|
return $this->typeHint; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param \ReflectionType $typeHint |
88
|
|
|
* @return AbstractPropertyDefinition |
89
|
|
|
*/ |
90
|
6 |
|
public function setTypeHint(\ReflectionType $typeHint): AbstractPropertyDefinition |
91
|
|
|
{ |
92
|
6 |
|
$this->typeHint = $typeHint; |
93
|
|
|
|
94
|
6 |
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return mixed |
99
|
|
|
*/ |
100
|
2 |
|
public function getValue() |
101
|
|
|
{ |
102
|
2 |
|
return $this->value; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param mixed $value |
107
|
|
|
* @return AbstractPropertyDefinition |
108
|
|
|
*/ |
109
|
3 |
|
public function setValue($value): AbstractPropertyDefinition |
110
|
|
|
{ |
111
|
3 |
|
$this->value = $value; |
112
|
|
|
|
113
|
3 |
|
return $this; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|