From 8301d06ef4a618046090d633fbdb284615793957 Mon Sep 17 00:00:00 2001 From: finchen Date: Thu, 8 Jan 2015 15:14:33 +1300 Subject: [PATCH] Update AddressGeolocation.php implements arrayaccess to e easily used with some bundles (had a problem with jms serializer) --- Geolocation/AddressGeolocation.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Geolocation/AddressGeolocation.php b/Geolocation/AddressGeolocation.php index ab9be619..ac95d74c 100644 --- a/Geolocation/AddressGeolocation.php +++ b/Geolocation/AddressGeolocation.php @@ -14,7 +14,7 @@ /** * @author Olivier Chauvel */ -class AddressGeolocation implements \Serializable +class AddressGeolocation implements \Serializable, \ArrayAccess { private $address; private $latitude; @@ -77,4 +77,24 @@ public function unserialize($serialized) $this->locality = $data['locality'] ?: null; $this->country = $data['country'] ?: null; } + + public function offsetExists($offset) + { + return isset($this->$offset); + } + + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + public function offsetGet($offset) + { + return $this->$offset; + } + + public function offsetUnset($offset) + { + $this->$offset = null; + } }