Skip to content

Commit 66fb057

Browse files
committed
Merge branch 'develop' into release/v0
2 parents 0a0cf88 + c76473d commit 66fb057

15 files changed

Lines changed: 427 additions & 31 deletions

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ php:
44
- 7.1
55
- 7.2
66
- 7.3
7+
- 7.4
78

89
before_script:
910
- travis_retry composer self-update
@@ -12,4 +13,4 @@ before_script:
1213
script:
1314
- vendor/bin/phpunit --exclude-group http
1415

15-
fast_finish: true
16+
fast_finish: true

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,47 @@ This provide simple functions to work with Google Maps APIs. You can find furthe
88
Google Maps provide many services, actually at this moment this package implements only **Geocoding** service but others will be available soon.
99

1010
## Reference & Documentation
11+
1112
Go to [complete reference](https://biscolab.com/google-maps-php-reference/) or read [documentation](https://gmaps-php-docs.biscolab.com/)
1213

1314
## Google Maps Services
1415

1516
### Ready
16-
* Geocoding :ballot_box_with_check:
17-
* Elevation :ballot_box_with_check:
18-
* Places :ballot_box_with_check:
17+
18+
- Geocoding :ballot_box_with_check:
19+
- Elevation :ballot_box_with_check:
20+
- Places :ballot_box_with_check:
21+
- Time Zone :ballot_box_with_check:
1922

2023
### ASAP
21-
* Directions (soon)
22-
* Distance Matrix (soon)
23-
* Road (soon)
24-
* Time Zone (soon)
24+
25+
- Directions (soon)
26+
- Distance Matrix (soon)
27+
- Road (soon)
2528

2629
### Not scheduled
27-
* Geolocation (not scheduled)
30+
31+
- Geolocation (not scheduled)
2832

2933
## Installation
3034

3135
You can install the package via composer:
36+
3237
```sh
3338
composer require biscolab/google-maps-php-sdk
3439
```
3540

3641
## Documentation
37-
Notice! The package is not yet stable, you may find trouble with your minimum stability settings.
38-
* [Complete documentation](https://gmaps-php-docs.biscolab.com/docs/getting-started)
39-
* [API reference](https://biscolab.com/google-maps-php-reference)
42+
43+
Notice! The package is not yet stable, you may find trouble with your minimum stability settings.
44+
45+
- [Complete documentation](https://gmaps-php-docs.biscolab.com/docs/getting-started)
46+
- [API reference](https://biscolab.com/google-maps-php-reference)
4047

4148
## Examples
4249

4350
Watch the [examples](https://github.com/biscolab/google-maps-php-sdk/tree/master/examples)
4451

4552
## License
53+
4654
[![MIT License](https://img.shields.io/github/license/biscolab/google-maps-php-sdk.svg)](https://github.com/biscolab/google-maps-php-sdk/blob/master/LICENSE)

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "biscolab/google-maps-php-sdk",
33
"description": "Google Maps PHP SDK.",
44
"license": "MIT",
5-
"version": "0.6.0",
5+
"version": "0.7.0",
66
"keywords": [
77
"google",
88
"maps",
@@ -46,4 +46,3 @@
4646
"test-no-http": "phpunit --exclude-group http"
4747
}
4848
}
49-

examples/Places/placesFindPlaceByPhoneNumber.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE
99
*/
1010

11-
use Biscolab\GoogleMaps\Api\P;
1211
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields;
1312

1413
// Run "composer install" command or change with your actual autoload.php file

examples/Places/placesFindPlaceByText.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE
99
*/
1010

11-
use Biscolab\GoogleMaps\Api\P;
1211
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields;
1312

1413
// Run "composer install" command or change with your actual autoload.php file

examples/Places/placesTextSearch.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE
99
*/
1010

11-
use Biscolab\GoogleMaps\Api\P;
1211
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields;
1312

1413
// Run "composer install" command or change with your actual autoload.php file

examples/TimeZone/timeZone.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/**
4+
* Copyright (c) 2019 - present
5+
* Google Maps PHP - timeZone.php
6+
* author: Roberto Belotti - [email protected]
7+
* web : robertobelotti.com, github.com/biscolab
8+
* Initial version created on: 9/10/2019
9+
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE
10+
*/
11+
12+
use Biscolab\GoogleMaps\Api\TimeZone;
13+
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields;
14+
use Biscolab\GoogleMaps\Fields\LatLngFields;
15+
use Biscolab\GoogleMaps\Object\Location;
16+
17+
// Run "composer install" command or change with your actual autoload.php file
18+
require '../../vendor/autoload.php';
19+
20+
// Further info about API key: https://developers.google.com/maps/documentation/timezone/get-api-key
21+
$timezone = new TimeZone([
22+
GoogleMapsApiConfigFields::KEY => 'YOUR_API_KEY'
23+
]);
24+
25+
// https://developers.google.com/maps/documentation/timezone/start#sample-request
26+
$location = new Location([LatLngFields::LAT => 38.908133, LatLngFields::LNG => -77.047119]);
27+
$timestamp = 1458000000;
28+
$results = $timezone->get($location, $timestamp);
29+
30+
// get dstOffset: should be 3600
31+
$results->getDdstOffset();
32+
33+
// get rawOffset: should be -18000
34+
$results->getRawOffset();
35+
36+
// get timeZoneId: should be "America/New_York"
37+
$results->getTimeZoneId();
38+
39+
// get timeZoneName: should be "Eastern Daylight Time"
40+
$results->getTimeZoneName();

src/Abstracts/AbstractObject.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function __call($name, $arguments)
175175

176176
$camel_field = (empty($match[0])) ? '' : $match[0];
177177

178-
$snake_field = camel2Snake($camel_field);
178+
$snake_field = $this->getFieldName($camel_field);
179179

180180
$field_type = (empty($this->typeCheck[$snake_field])) ? null : $this->typeCheck[$snake_field];
181181

@@ -189,4 +189,15 @@ public function __call($name, $arguments)
189189
}
190190
}
191191

192+
/**
193+
* @param string $initial_field_name
194+
*
195+
* @return string
196+
*/
197+
protected function getFieldName(string $initial_field_name): string
198+
{
199+
200+
return camel2Snake($initial_field_name);
201+
}
202+
192203
}

src/Api/TimeZone.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2019 - present
4+
* Google Maps PHP - TimeZone.php
5+
* author: Roberto Belotti - [email protected]
6+
* web : robertobelotti.com, github.com/biscolab
7+
* Initial version created on: 8/10/2019
8+
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE
9+
*/
10+
11+
namespace Biscolab\GoogleMaps\Api;
12+
13+
use Biscolab\GoogleMaps\Abstracts\Api;
14+
use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields;
15+
use Biscolab\GoogleMaps\Http\GoogleMapsResult;
16+
use Biscolab\GoogleMaps\Http\Result\ElevationResultsCollection;
17+
use Biscolab\GoogleMaps\Http\Result\TimeZoneResult;
18+
use Biscolab\GoogleMaps\Object\Location;
19+
20+
/**
21+
* Class TimeZone
22+
* @package Biscolab\GoogleMaps\Api
23+
*
24+
* @since 0.7.0
25+
* @see https://developers.google.com/maps/documentation/timezone/intro
26+
*/
27+
class TimeZone extends Api
28+
{
29+
30+
/**
31+
* @var string
32+
*/
33+
const SERVICE_ENDPOINT = 'timezone';
34+
35+
/**
36+
* @var string
37+
*/
38+
protected $result_type = TimeZoneResult::class;
39+
40+
/**
41+
* @param Location $location
42+
* @param int $timestamp
43+
* @param string|null $language
44+
*
45+
* @return GoogleMapsResult
46+
*/
47+
public function get(Location $location, int $timestamp, string $language = null): GoogleMapsResult
48+
{
49+
50+
$params = [
51+
GoogleMapsRequestFields::LOCATION => $location,
52+
GoogleMapsRequestFields::TIMESTAMP => $timestamp,
53+
];
54+
55+
if ($language) {
56+
$params[GoogleMapsRequestFields::LANGUAGE] = $language;
57+
}
58+
59+
return $this->callApi($params);
60+
}
61+
}

src/Fields/GoogleMapsRequestFields.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,10 @@ class GoogleMapsRequestFields
176176
* @since 0.6.0
177177
*/
178178
const MAXHEIGHT = 'maxheight';
179+
180+
/**
181+
* @var string timestamp
182+
* @since 0.7.0
183+
*/
184+
const TIMESTAMP = 'timestamp';
179185
}

0 commit comments

Comments
 (0)