1 | <?php |
||
30 | abstract class AbstractBinding implements Binding |
||
31 | { |
||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | private $typeName; |
||
36 | |||
37 | /** |
||
38 | * @var BindingType|null |
||
39 | */ |
||
40 | private $type; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | private $userParameterValues = array(); |
||
46 | |||
47 | /** |
||
48 | * @var array |
||
49 | */ |
||
50 | private $parameterValues = array(); |
||
51 | |||
52 | /** |
||
53 | * Creates a new binding. |
||
54 | * |
||
55 | * You can pass parameters that have been defined for the type. If you pass |
||
56 | * unknown parameters, or if a required parameter is missing, an exception |
||
57 | * is thrown. |
||
58 | * |
||
59 | * All parameters that you do not set here will receive the default values |
||
60 | * set for the parameter. |
||
61 | * |
||
62 | * @param string $typeName The name of the type to bind against. |
||
63 | * @param array $parameterValues The values of the parameters defined |
||
64 | * for the type. |
||
65 | * |
||
66 | * @throws NoSuchParameterException If an invalid parameter was passed. |
||
67 | * @throws MissingParameterException If a required parameter was not passed. |
||
68 | */ |
||
69 | 132 | public function __construct($typeName, array $parameterValues = array()) |
|
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | 106 | public function initialize(BindingType $type) |
|
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | 2 | public function isInitialized() |
|
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | 98 | public function getTypeName() |
|
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | 4 | public function getType() |
|
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | 10 | public function getParameterValues($includeDefault = true) |
|
145 | |||
146 | /** |
||
147 | * {@inheritdoc} |
||
148 | */ |
||
149 | public function hasParameterValues($includeDefault = true) |
||
157 | |||
158 | /** |
||
159 | * {@inheritdoc} |
||
160 | */ |
||
161 | 32 | public function getParameterValue($parameterName, $includeDefault = true) |
|
171 | |||
172 | /** |
||
173 | * {@inheritdoc} |
||
174 | */ |
||
175 | 10 | public function hasParameterValue($parameterName, $includeDefault = true) |
|
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | */ |
||
187 | 73 | public function serialize() |
|
195 | |||
196 | /** |
||
197 | * {@inheritdoc} |
||
198 | */ |
||
199 | 30 | public function unserialize($serialized) |
|
205 | |||
206 | /** |
||
207 | * {@inheritdoc} |
||
208 | */ |
||
209 | 58 | public function equals(Binding $other) |
|
210 | { |
||
211 | 58 | if (get_class($this) !== get_class($other)) { |
|
212 | return false; |
||
213 | } |
||
214 | |||
215 | /** @var AbstractBinding $other */ |
||
216 | 58 | if ($this->typeName !== $other->typeName) { |
|
217 | return false; |
||
218 | } |
||
219 | |||
220 | 58 | return $this->userParameterValues === $other->userParameterValues; |
|
221 | } |
||
222 | |||
223 | 73 | protected function preSerialize(array &$data) |
|
228 | |||
229 | 30 | protected function postUnserialize(array &$data) |
|
235 | |||
236 | 97 | private function assertParameterValuesValid(array $parameterValues, BindingType $type) |
|
252 | } |
||
253 |