-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into release/v0
- Loading branch information
Showing
15 changed files
with
427 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (c) 2019 - present | ||
* Google Maps PHP - timeZone.php | ||
* author: Roberto Belotti - roby.belotti@gmail.com | ||
* web : robertobelotti.com, github.com/biscolab | ||
* Initial version created on: 9/10/2019 | ||
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE | ||
*/ | ||
|
||
use Biscolab\GoogleMaps\Api\TimeZone; | ||
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields; | ||
use Biscolab\GoogleMaps\Fields\LatLngFields; | ||
use Biscolab\GoogleMaps\Object\Location; | ||
|
||
// Run "composer install" command or change with your actual autoload.php file | ||
require '../../vendor/autoload.php'; | ||
|
||
// Further info about API key: https://developers.google.com/maps/documentation/timezone/get-api-key | ||
$timezone = new TimeZone([ | ||
GoogleMapsApiConfigFields::KEY => 'YOUR_API_KEY' | ||
]); | ||
|
||
// https://developers.google.com/maps/documentation/timezone/start#sample-request | ||
$location = new Location([LatLngFields::LAT => 38.908133, LatLngFields::LNG => -77.047119]); | ||
$timestamp = 1458000000; | ||
$results = $timezone->get($location, $timestamp); | ||
|
||
// get dstOffset: should be 3600 | ||
$results->getDdstOffset(); | ||
|
||
// get rawOffset: should be -18000 | ||
$results->getRawOffset(); | ||
|
||
// get timeZoneId: should be "America/New_York" | ||
$results->getTimeZoneId(); | ||
|
||
// get timeZoneName: should be "Eastern Daylight Time" | ||
$results->getTimeZoneName(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 - present | ||
* Google Maps PHP - TimeZone.php | ||
* author: Roberto Belotti - roby.belotti@gmail.com | ||
* web : robertobelotti.com, github.com/biscolab | ||
* Initial version created on: 8/10/2019 | ||
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Biscolab\GoogleMaps\Api; | ||
|
||
use Biscolab\GoogleMaps\Abstracts\Api; | ||
use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields; | ||
use Biscolab\GoogleMaps\Http\GoogleMapsResult; | ||
use Biscolab\GoogleMaps\Http\Result\ElevationResultsCollection; | ||
use Biscolab\GoogleMaps\Http\Result\TimeZoneResult; | ||
use Biscolab\GoogleMaps\Object\Location; | ||
|
||
/** | ||
* Class TimeZone | ||
* @package Biscolab\GoogleMaps\Api | ||
* | ||
* @since 0.7.0 | ||
* @see https://developers.google.com/maps/documentation/timezone/intro | ||
*/ | ||
class TimeZone extends Api | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
const SERVICE_ENDPOINT = 'timezone'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $result_type = TimeZoneResult::class; | ||
|
||
/** | ||
* @param Location $location | ||
* @param int $timestamp | ||
* @param string|null $language | ||
* | ||
* @return GoogleMapsResult | ||
*/ | ||
public function get(Location $location, int $timestamp, string $language = null): GoogleMapsResult | ||
{ | ||
|
||
$params = [ | ||
GoogleMapsRequestFields::LOCATION => $location, | ||
GoogleMapsRequestFields::TIMESTAMP => $timestamp, | ||
]; | ||
|
||
if ($language) { | ||
$params[GoogleMapsRequestFields::LANGUAGE] = $language; | ||
} | ||
|
||
return $this->callApi($params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 - present | ||
* Google Maps PHP - TimeZoneResult.php | ||
* author: Roberto Belotti - roby.belotti@gmail.com | ||
* web : robertobelotti.com, github.com/biscolab | ||
* Initial version created on: 8/10/2019 | ||
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Biscolab\GoogleMaps\Http\Result; | ||
|
||
use Biscolab\GoogleMaps\Fields\GoogleMapsResultFields; | ||
use Biscolab\GoogleMaps\Http\GoogleMapsResult; | ||
|
||
/** | ||
* Class TimeZoneResult | ||
* | ||
* @method setDstOffset(int $dstOffset) | ||
* @method setRawOffset(int $rawOffset) | ||
* @method setTimeZoneId(string $timeZoneId) | ||
* @method setTimeZoneName(string $timeZoneName) | ||
* | ||
* @method int getDstOffset() | ||
* @method int getRawOffset() | ||
* @method string getTimeZoneId() | ||
* @method string getTimeZoneName() | ||
* @since 0.7.0 | ||
*/ | ||
class TimeZoneResult extends GoogleMapsResult | ||
{ | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $dstOffset = 0; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $rawOffset = 0; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $timeZoneId = ''; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $timeZoneName = ''; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $typeCheck = [ | ||
GoogleMapsResultFields::DST_OFFSET => 'int', | ||
GoogleMapsResultFields::RAW_OFFSET => 'int', | ||
GoogleMapsResultFields::TIMEZONE_ID => 'string', | ||
GoogleMapsResultFields::TIMEZONE_NAME => 'string', | ||
]; | ||
|
||
/** | ||
* @param string $initial_field_name | ||
* | ||
* @return string | ||
*/ | ||
protected function getFieldName(string $initial_field_name): string | ||
{ | ||
|
||
return lcfirst($initial_field_name); | ||
} | ||
|
||
} |
Oops, something went wrong.