/**
  * @param Paysera_WalletApi_Entity_Location $location
  * @param DateTime $date
  * @return bool
  */
 public function isLocationOpen(Paysera_WalletApi_Entity_Location $location, DateTime $date = null)
 {
     if (!$location->getWorkingHours()) {
         return true;
     }
     if ($date === null) {
         $date = new DateTime();
     }
     $dateYesterday = clone $date;
     $dateYesterday->sub(new DateInterval('P1D'));
     $dayOfWeek = strtolower(date('l', $date->getTimestamp()));
     $dayOfWeekYesterday = strtolower(date('l', $dateYesterday->getTimestamp()));
     foreach ($location->getWorkingHours() as $workingHours) {
         if ($workingHours->getDay() === $dayOfWeek && $this->isWorkingHoursActiveByDate($workingHours, $date, $date)) {
             return true;
         }
         if ($workingHours->getDay() === $dayOfWeekYesterday && $this->isWorkingHoursActiveByDate($workingHours, $dateYesterday, $date)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Encode location
  *
  * @param Paysera_WalletApi_Entity_Location $object
  *
  * @return array
  */
 public function encodeLocation(Paysera_WalletApi_Entity_Location $object)
 {
     $workingHours = array();
     foreach ($object->getWorkingHours() as $dayWorkingHours) {
         $workingHours = array_merge($workingHours, $this->encodeDayWorkingHours($dayWorkingHours));
     }
     $prices = array();
     foreach ($object->getPrices() as $price) {
         $prices[] = $this->encodeLocationPrice($price);
     }
     $services = $this->encodeLocationServices($object->getServices(), $object->getPayCategories());
     return array('id' => $object->getId(), 'title' => $object->getTitle(), 'description' => $object->getDescription(), 'address' => $object->getAddress(), 'lat' => $object->getLat(), 'lng' => $object->getLng(), 'radius' => $object->getRadius(), 'working_hours' => $workingHours, 'prices' => $prices, 'status' => $object->getStatus(), 'services' => $services, 'public' => $object->getPublic());
 }