langleyfoxall / php-simple-google-maps

This package provides a simple PHP client for various Google Maps APIs.
https://packagist.org/packages/langleyfoxall/simple-google-maps
GNU Lesser General Public License v3.0
2 stars 3 forks source link

Add additional methods to mutate time & distance #3

Open ash123456789 opened 5 years ago

ash123456789 commented 5 years ago

It would be very convenient if you could mutate the time that is calculated, without needing to perform additional processing of the data outside of the package.

Time

If we use the demo as an example, it currently returns the information in seconds. What I propose would do the following.

$journey->duration()->toMinutes()

This would then return, for example, 5 mins. Additional options would also be really handy, e.g. toHours().

Distance

Something similar could also be done to the distance.

$journey->distance()->toMiles()
DivineOmega commented 5 years ago

This is a good idea.

However, the current duration() and distance() methods do not return objects, so we could not chain methods in this manner. It's also worth considering it we want to apply this functionality to the Journey Steps as well.