Skip to content

Commit

Permalink
Merge branch 'release/v0'
Browse files Browse the repository at this point in the history
  • Loading branch information
biscolab committed Dec 1, 2021
2 parents ee0e862 + 5961ab0 commit 35ac500
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 56 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "biscolab/google-maps-php-sdk",
"description": "Google Maps PHP SDK.",
"license": "MIT",
"version": "0.8.2",
"version": "0.9.0",
"keywords": [
"google",
"maps",
Expand All @@ -18,12 +18,12 @@
}
],
"require": {
"php": ">=7.1.1",
"guzzlehttp/guzzle": "5.*|6.*"
"php": "^8.0",
"guzzlehttp/guzzle": "5.*|6.*|7.*"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "7.*|8.*|^9.0",
"psr/log": "^1.0",
"phpdocumentor/reflection-docblock": "~2.0",
"sami/sami": "^4.1"
Expand Down
16 changes: 8 additions & 8 deletions src/Abstracts/AbstractCollection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2018 - present
* Google Maps PHP - AbstractCollection.php
Expand Down Expand Up @@ -190,7 +191,7 @@ public function last()
*
* @return mixed|null
*/
public function current()
public function current(): mixed
{

return $this->get($this->index);
Expand All @@ -201,7 +202,7 @@ public function current()
*
* @return mixed|null
*/
public function next()
public function next(): void
{

++$this->index;
Expand All @@ -212,7 +213,7 @@ public function next()
*
* @return mixed|null
*/
public function key()
public function key(): mixed
{

return $this->index;
Expand All @@ -223,7 +224,7 @@ public function key()
*
* @return mixed|null
*/
public function valid()
public function valid(): bool
{

return !empty($this->current());
Expand All @@ -234,10 +235,9 @@ public function valid()
*
* @return mixed|null
*/
public function rewind()
public function rewind(): void
{

return $this->index = 0;
$this->index = 0;
}

}
}
7 changes: 6 additions & 1 deletion src/Abstracts/AbstractObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ public function toArray(): array

foreach ($fields as $field_name => $field_value) {

if (!is_scalar($field_value) && method_exists($field_value, 'toJson')) {
if (
$field_value !== null &&
!is_array($field_value) &&
!is_scalar($field_value) &&
method_exists($field_value, 'toJson')
) {
$fields[$field_name] = $field_value->toArray();
}
}
Expand Down
19 changes: 10 additions & 9 deletions tests/Elevation/GoogleMapsElevationHttpTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2018 - present
* Google Maps PHP - GoogleMapsElevationHttpTest.php author: Roberto Belotti - roby.belotti@gmail.com
Expand Down Expand Up @@ -34,7 +35,7 @@ class GoogleMapsElevationHttpTest extends TestCase
*/
protected $elevation_with_sensor;

public function setUp()
public function setUp(): void
{

$this->elevation_with_key = new Elevation([
Expand All @@ -54,10 +55,14 @@ public function setUp()
public function testCheckElevationConfig()
{

$this->assertEquals(Elevation::SERVICE_ENDPOINT,
$this->elevation_with_key->getGoogleMapsApi()->getServiceEndpoint());
$this->assertEquals(getenv("API_KEY"),
$this->elevation_with_key->getGoogleMapsApi()->getKey());
$this->assertEquals(
Elevation::SERVICE_ENDPOINT,
$this->elevation_with_key->getGoogleMapsApi()->getServiceEndpoint()
);
$this->assertEquals(
getenv("API_KEY"),
$this->elevation_with_key->getGoogleMapsApi()->getKey()
);
$this->assertEquals('', $this->elevation_no_key->getGoogleMapsApi()->getKey());
}

Expand Down Expand Up @@ -92,7 +97,6 @@ public function testCheckGeocodingFromLocation()
$this->assertEquals(39.73915360, $array_result['location']['lat']);
$this->assertEquals(-104.9847034, $array_result['location']['lng']);
$this->assertEquals(1608.6379394531, $array_result['elevation']);

}

/**
Expand Down Expand Up @@ -133,7 +137,6 @@ public function testCheckGeocodingFromLocationMulti()
$this->assertEquals(50.123, $array_last_result['location']['lat']);
$this->assertEquals(99.456, $array_last_result['location']['lng']);
$this->assertEquals(2013.5008544922, $array_last_result['elevation']);

}

/**
Expand Down Expand Up @@ -174,7 +177,6 @@ public function testCheckElevationBySampledPath()
$this->assertEquals(50.123, $array_last_result['location']['lat']);
$this->assertEquals(99.456, $array_last_result['location']['lng']);
$this->assertEquals(2013.5008544922, $array_last_result['elevation']);

}

/**
Expand Down Expand Up @@ -217,6 +219,5 @@ public function testCheckElevationBySampledPathPAssingPath()
$this->assertEquals(50.123, $array_last_result['location']['lat']);
$this->assertEquals(99.456, $array_last_result['location']['lng']);
$this->assertEquals(2013.5008544922, $array_last_result['elevation']);

}
}
11 changes: 6 additions & 5 deletions tests/Elevation/GoogleMapsElevationPositionalTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2018 - present
* Google Maps PHP - GoogleMapsElevationPositionalTesttionalTest.php
Expand Down Expand Up @@ -49,7 +50,7 @@ class GoogleMapsElevationPositionalTest extends TestCase
*/
protected $mock_response_ko;

public function setUp()
public function setUp(): void
{

// This is the sample value from Google Maps official documentation
Expand Down Expand Up @@ -92,8 +93,10 @@ public function setUp()
public function testCheckElevationConfig()
{

$this->assertEquals(Elevation::SERVICE_ENDPOINT,
$this->elevation_with_key->getGoogleMapsApi()->getServiceEndpoint());
$this->assertEquals(
Elevation::SERVICE_ENDPOINT,
$this->elevation_with_key->getGoogleMapsApi()->getServiceEndpoint()
);
$this->assertEquals('MyKey', $this->elevation_with_key->getGoogleMapsApi()->getKey());
$this->assertEquals('', $this->elevation_no_key->getGoogleMapsApi()->getKey());
}
Expand Down Expand Up @@ -149,7 +152,6 @@ public function testCheckElevationResponseOk()
$this->assertArrayHasKey('resolution', $array_result);

$this->assertEquals(200, $response->getHttpStatusCode());

}

public function testResponseKO()
Expand All @@ -158,5 +160,4 @@ public function testResponseKO()
$this->expectException(RequestException::class);
new GoogleMapsResponse($this->mock_response_ko);
}

}
17 changes: 9 additions & 8 deletions tests/Elevation/GoogleMapsElevationSampledTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2018 - present
* Google Maps PHP - GoogleMapsElevationSampledTest.php
Expand Down Expand Up @@ -49,7 +50,7 @@ class GoogleMapsElevationSampledTest extends TestCase
*/
protected $mock_response_ko;

public function setUp()
public function setUp(): void
{

// This is the sample value from Google Maps official documentation
Expand Down Expand Up @@ -111,7 +112,6 @@ public function testCheckElevationSampledResponseOk()
$this->assertArrayHasKey('resolution', $array_result);

$this->assertEquals(200, $response->getHttpStatusCode());

}

public function testExceptionIfPathItemsLessThanTwoArray()
Expand Down Expand Up @@ -144,15 +144,16 @@ public function testExceptionIfSamplesLessThanOne()

$this->expectException(InvalidArgumentException::class);
$this->elevation_with_key->getBySampledPath([
new Location([
LatLngFields::LAT => 39.73915360,
LatLngFields::LNG => -104.9847034,
],
new Location(
[
LatLngFields::LAT => 39.73915360,
LatLngFields::LNG => -104.9847034,
],
new Location([
LatLngFields::LAT => 50.123,
LatLngFields::LNG => 99.456,
]))
])
)
], 0);
}

}
2 changes: 1 addition & 1 deletion tests/Geocoding/GoogleMapsGeocodingHttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GoogleMapsGeocodingHttpTest extends TestCase
*/
protected $geocoding_with_sensor;

public function setUp()
public function setUp(): void
{

$this->geocoding_with_key = new Geocoding([
Expand Down
2 changes: 1 addition & 1 deletion tests/Geocoding/GoogleMapsGeocodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GoogleMapsGeocodingTest extends TestCase
*/
protected $mock_response_ko;

public function setUp()
public function setUp(): void
{

// This is the sample value from Google Maps official documentation
Expand Down
4 changes: 2 additions & 2 deletions tests/Object/AddressComponentTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2018 - present
* Google Maps PHP - AddressComponentTest.php
Expand Down Expand Up @@ -32,7 +33,7 @@ class AddressComponentTest extends TestCase
*/
private $address_component_2;

public function setUp()/* The :void return type declaration that should be here would cause a BC issue */
public function setUp(): void/* The :void return type declaration that should be here would cause a BC issue */
{

parent::setUp(); // TODO: Change the autogenerated stub
Expand Down Expand Up @@ -73,7 +74,6 @@ public function testAddressComponentInit()

$this->assertEquals(2, count($address_component->getTypes()));
$this->assertArrayNotHasKey(3, $address_component->getTypes());

}

/**
Expand Down
6 changes: 2 additions & 4 deletions tests/Object/GeometryTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2018 - present
* Google Maps PHP - GeometryTest.php
Expand Down Expand Up @@ -28,7 +29,7 @@ class GeometryTest extends TestCase
*/
protected $geometry;

public function setUp()/* The :void return type declaration that should be here would cause a BC issue */
public function setUp(): void/* The :void return type declaration that should be here would cause a BC issue */
{

parent::setUp(); // TODO: Change the autogenerated stub
Expand Down Expand Up @@ -56,7 +57,6 @@ public function testLocationSetterGetter()

$this->assertEquals(20, $geometry->getLocation()->getLat());
$this->assertEquals(33, $geometry->getLocation()->getLng());

}

/**
Expand All @@ -79,7 +79,6 @@ public function testLocationSetterGetterViaArray()

$this->assertEquals(20, $geometry->getLocation()->getLat());
$this->assertEquals(33, $geometry->getLocation()->getLng());

}

/**
Expand All @@ -93,6 +92,5 @@ public function testLocationTypeSetterGetter()
$geometry->setLocationType(GeometryLocationTypeValues::ROOFTOP);

$this->assertEquals(GeometryLocationTypeValues::ROOFTOP, $geometry->getLocationType());

}
}
4 changes: 2 additions & 2 deletions tests/Object/LatLngBountTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2018 - present
* Google Maps PHP - LatLngBountTest.php
Expand Down Expand Up @@ -28,7 +29,7 @@ class LatLngBountTest extends TestCase
*/
private $lat_lng_bounds;

public function setUp()/* The :void return type declaration that should be here would cause a BC issue */
public function setUp(): void/* The :void return type declaration that should be here would cause a BC issue */
{

parent::setUp(); // TODO: Change the autogenerated stub
Expand Down Expand Up @@ -67,6 +68,5 @@ public function testLatLngBoundSetterGetter()
LatLngFields::LNG => 3.6370,
],
]), $lat_lng_bounds);

}
}
4 changes: 2 additions & 2 deletions tests/Object/ViewportTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2018 - present
* Google Maps PHP - ViewportTest.php
Expand Down Expand Up @@ -29,7 +30,7 @@ class ViewportTest extends TestCase
*/
private $viewport;

public function setUp()/* The :void return type declaration that should be here would cause a BC issue */
public function setUp(): void/* The :void return type declaration that should be here would cause a BC issue */
{

parent::setUp(); // TODO: Change the autogenerated stub
Expand Down Expand Up @@ -68,6 +69,5 @@ public function testViewportSetterGetter()
LatLngFields::LNG => 3.6370,
],
]), $viewport);

}
}
5 changes: 2 additions & 3 deletions tests/Places/GoogleMapsPlacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GoogleMapsPlacesTest extends TestCase
*/
protected $mock_nearby_search_response_ok;

public function setUp()
public function setUp(): void
{

$this->place_with_key = new Places([
Expand Down Expand Up @@ -498,7 +498,6 @@ public function testTextSearch()
$result = $this->place_with_key->textSearch("restaurants in Sydney");
$this->assertInstanceOf(PlaceResultsCollection::class, $result);
$this->assertEquals(20, $result->count());
$this->assertEquals("ChIJxXSgfDyuEmsR3X5VXGjBkFg", $result->first()->getPlaceId());
$this->assertTrue($this->place_with_key->responseHasNewPage());
}

Expand All @@ -510,7 +509,7 @@ public function testPlaceDetails()
{
$result = $this->place_with_key->details("ChIJN1t_tDeuEmsRUsoyG83frY4");
$this->assertInstanceOf(PlacesResult::class, $result);
$this->assertEquals('4f89212bf76dde31f092cfc14d7506555d85b5c7', $result->getId());
$this->assertEquals('ChIJN1t_tDeuEmsRUsoyG83frY4', $result->getPlaceId());
}

/**
Expand Down
Loading

0 comments on commit 35ac500

Please sign in to comment.