File tree Expand file tree Collapse file tree 1 file changed +22
-11
lines changed Expand file tree Collapse file tree 1 file changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,13 @@ final class AddressBuilder
7979 */
8080 private $ timezone ;
8181
82+ /**
83+ * A storage for extra parameters.
84+ *
85+ * @var array
86+ */
87+ private $ data = [];
88+
8289 /**
8390 * @param string $providedBy
8491 */
@@ -277,34 +284,38 @@ public function setTimezone($timezone)
277284 }
278285
279286 /**
280- * @param $name
281- * @param $value
287+ * @param string $name
288+ * @param mixed $value
282289 *
283290 * @return $this
284291 */
285- public function setValue ($ name , $ value )
292+ public function setValue (string $ name , $ value )
286293 {
287- $ this ->$ name = $ value ;
294+ $ this ->data [ $ name] = $ value ;
288295
289296 return $ this ;
290297 }
291298
292299 /**
293- * @param $name
294- * @param null $default
300+ * @param string $name
301+ * @param mixed| null $default
295302 */
296- public function getValue ($ name , $ default = null )
303+ public function getValue (string $ name , $ default = null )
297304 {
298- return $ this ->$ name ?? $ default ;
305+ if ($ this ->hasValue ($ name )) {
306+ return $ this ->data [$ name ];
307+ }
308+
309+ return $ default ;
299310 }
300311
301312 /**
302- * @param $name
313+ * @param string $name
303314 *
304315 * @return bool
305316 */
306- public function hasValue ($ name )
317+ public function hasValue (string $ name ): bool
307318 {
308- return property_exists ( $ this , $ name );
319+ return array_key_exists ( $ name , $ this -> data );
309320 }
310321}
You can’t perform that action at this time.
0 commit comments