コード例 #1
0
ファイル: PlaceDetail.php プロジェクト: cawaphp/google-maps
 /**
  * @param array $data
  *
  * @return $this|self
  */
 protected static function map(array &$data)
 {
     /** @var PlaceDetail $return */
     $return = parent::map($data);
     $return->phone = self::extract($data, 'international_phone_number');
     $return->website = self::extract($data, 'website');
     $return->rating = self::extract($data, 'rating');
     if (isset($data['reviews'])) {
         foreach (self::extract($data, 'reviews') as $current) {
             $return->reviews[] = new Review($current['author_name'], $current['language'], $current['rating'], $current['text'], $current['time'], $current['author_url'] ?? null);
         }
     }
     if (isset($data['opening_hours']['periods'])) {
         foreach (self::extract($data, 'opening_hours/periods') as $current) {
             if (isset($current['open']) && isset($current['close'])) {
                 list($hour, $min) = self::extractHourMin($current['open']);
                 $open = new DateTime();
                 $open->setTimezone('UTC');
                 $open->next($current['open']['day']);
                 $open->hour($hour);
                 $open->minute($min);
                 $open->second(0);
                 $open->addMinutes(-$return->utcOffset);
                 $open->setTimezone(date_default_timezone_get());
                 list($hour, $min) = self::extractHourMin($current['close']);
                 $close = new DateTime();
                 $close->setTimezone('UTC');
                 $close->next($current['close']['day']);
                 $close->hour($hour);
                 $close->minute($min);
                 $close->second(0);
                 $close->addMinutes(-$return->utcOffset);
                 $close->setTimezone(date_default_timezone_get());
                 $return->openingHours[] = new OpeningHoursPeriod($open, $close);
             }
         }
     }
     return $return;
 }
コード例 #2
0
ファイル: Place.php プロジェクト: cawaphp/google-maps
 /**
  * @return array|PlaceModel[]
  */
 public static function nextPage()
 {
     if (!self::$nextPage) {
         return [];
     }
     // @see http://stackoverflow.com/a/12825461/1590168 must wait that the token is available
     sleep(2);
     $data = self::query(self::$nextPage['url'], array_merge(self::$nextPage['params'], []));
     $return = [];
     foreach ($data['results'] as $current) {
         $return[] = PlaceModel::parse($current);
     }
     if (isset($data['next_page_token'])) {
         self::$nextPage['params']['pagetoken'] = $data['next_page_token'];
     }
     return $return;
 }