/** * Decodes location * * @param array $data * * @return Paysera_WalletApi_Entity_Location */ public function decodeLocation(array $data) { $location = new Paysera_WalletApi_Entity_Location(); $location->setId($data['id']); $location->setTitle($data['title']); if (!empty($data['description'])) { $location->setDescription($data['description']); } $location->setAddress($data['address']); $location->setRadius($data['radius']); if (!empty($data['lat'])) { $location->setLat((double) $data['lat']); } if (!empty($data['lng'])) { $location->setLng((double) $data['lng']); } if (!empty($data['prices'])) { $result = array(); foreach ($data['prices'] as $price) { $result[] = $this->decodeLocationPrice($price); } $location->setPrices($result); } if (!empty($data['working_hours'])) { foreach ($data['working_hours'] as $day => $dayWorkingHour) { $location->addWorkingHours($this->decodeDayWorkingHours($day, $dayWorkingHour)); } } if (!empty($data['images']['pin_open'])) { $location->setImagePinOpen($data['images']['pin_open']); } if (!empty($data['images']['pin_closed'])) { $location->setImagePinClosed($data['images']['pin_closed']); } if (!empty($data['services'])) { $services = array(); foreach ($data['services'] as $key => $val) { if (!empty($val['available']) && $val['available'] === true) { $services[] = $key; } } $location->setServices($services); if (!empty($data['services']['pay']['categories'])) { $location->setPayCategories($data['services']['pay']['categories']); } } if (!empty($data['status'])) { $location->setStatus($data['status']); } if (isset($data['public'])) { $location->setPublic((bool) $data['public']); } return $location; }