@@ -16,43 +16,43 @@ |
||
16 | 16 | */ |
17 | 17 | class GoogleMapsRequestFields { |
18 | 18 | |
19 | - /** |
|
20 | - * string: key |
|
21 | - */ |
|
22 | - const KEY = 'key'; |
|
23 | - |
|
24 | - /** |
|
25 | - * string: sensor |
|
26 | - */ |
|
27 | - const SENSOR = 'sensor'; |
|
28 | - |
|
29 | - /** |
|
30 | - * string: latlng |
|
31 | - */ |
|
32 | - const LATLNG = 'latlng'; |
|
33 | - |
|
34 | - /** |
|
35 | - * string: address |
|
36 | - */ |
|
37 | - const ADDRESS = 'address'; |
|
38 | - |
|
39 | - /** |
|
40 | - * string: place_id |
|
41 | - */ |
|
42 | - const PLACE_ID = 'place_id'; |
|
43 | - |
|
44 | - /** |
|
45 | - * string: locations |
|
46 | - */ |
|
47 | - const LOCATIONS = 'locations'; |
|
48 | - |
|
49 | - /** |
|
50 | - * string: path |
|
51 | - */ |
|
52 | - const PATH = 'path'; |
|
53 | - |
|
54 | - /** |
|
55 | - * string: samples |
|
56 | - */ |
|
57 | - const SAMPLES = 'samples'; |
|
19 | + /** |
|
20 | + * string: key |
|
21 | + */ |
|
22 | + const KEY = 'key'; |
|
23 | + |
|
24 | + /** |
|
25 | + * string: sensor |
|
26 | + */ |
|
27 | + const SENSOR = 'sensor'; |
|
28 | + |
|
29 | + /** |
|
30 | + * string: latlng |
|
31 | + */ |
|
32 | + const LATLNG = 'latlng'; |
|
33 | + |
|
34 | + /** |
|
35 | + * string: address |
|
36 | + */ |
|
37 | + const ADDRESS = 'address'; |
|
38 | + |
|
39 | + /** |
|
40 | + * string: place_id |
|
41 | + */ |
|
42 | + const PLACE_ID = 'place_id'; |
|
43 | + |
|
44 | + /** |
|
45 | + * string: locations |
|
46 | + */ |
|
47 | + const LOCATIONS = 'locations'; |
|
48 | + |
|
49 | + /** |
|
50 | + * string: path |
|
51 | + */ |
|
52 | + const PATH = 'path'; |
|
53 | + |
|
54 | + /** |
|
55 | + * string: samples |
|
56 | + */ |
|
57 | + const SAMPLES = 'samples'; |
|
58 | 58 | } |
59 | 59 | \ No newline at end of file |
@@ -20,13 +20,13 @@ |
||
20 | 20 | */ |
21 | 21 | class Path extends AbstractCollection { |
22 | 22 | |
23 | - /** |
|
24 | - * @param $item |
|
25 | - * |
|
26 | - * @return Location |
|
27 | - */ |
|
28 | - protected function parseItem($item) { |
|
23 | + /** |
|
24 | + * @param $item |
|
25 | + * |
|
26 | + * @return Location |
|
27 | + */ |
|
28 | + protected function parseItem($item) { |
|
29 | 29 | |
30 | - return ($item instanceof Location) ? $item : new Location($item); |
|
31 | - } |
|
30 | + return ($item instanceof Location) ? $item : new Location($item); |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -27,93 +27,93 @@ |
||
27 | 27 | */ |
28 | 28 | class Elevation extends Api { |
29 | 29 | |
30 | - /** |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - const SERVICE_ENDPOINT = 'elevation'; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - protected $result_collection = ElevationResultsCollection::class; |
|
39 | - |
|
40 | - /** |
|
41 | - * Positional Requests |
|
42 | - * |
|
43 | - * @param LatLng|string|array $locations |
|
44 | - * This parameter takes either a single location or multiple locations passed as an array or as an encoded polyline |
|
45 | - * |
|
46 | - * @return GoogleMapsResultsCollection |
|
47 | - * |
|
48 | - * @since 0.3.0 |
|
49 | - */ |
|
50 | - public function getByLocations($locations): GoogleMapsResultsCollection { |
|
51 | - |
|
52 | - $locations = $this->parseLocations($locations); |
|
53 | - |
|
54 | - $request = $this->createRequest([ |
|
55 | - GoogleMapsRequestFields::LOCATIONS => $locations |
|
56 | - ]); |
|
57 | - |
|
58 | - return $this->getResultsCollections($request); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param array|string $locations |
|
63 | - * |
|
64 | - * @return string |
|
65 | - * |
|
66 | - * @since 0.3.0 |
|
67 | - */ |
|
68 | - public function parseLocations($locations): string { |
|
69 | - |
|
70 | - if($locations instanceof Path) { |
|
71 | - $locations = $locations->toArray(); |
|
72 | - } |
|
73 | - |
|
74 | - if (is_array($locations)) { |
|
75 | - $locations = implode('|', array_map(function ($item) { |
|
76 | - |
|
77 | - return (string)$item; |
|
78 | - }, $locations)); |
|
79 | - } |
|
80 | - |
|
81 | - return (string)$locations; |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * Sampled Path Requests |
|
86 | - * |
|
87 | - * @param array|string $path |
|
88 | - * This parameter takes either a multiple locations passed as an array or as an encoded polyline |
|
89 | - * |
|
90 | - * @param int $samples |
|
91 | - * This will be the number of results as well |
|
92 | - * |
|
93 | - * @throws InvalidArgumentException |
|
94 | - * @return GoogleMapsResultsCollection |
|
95 | - * |
|
96 | - * @since 0.4.0 |
|
97 | - */ |
|
98 | - public function getBySampledPath($path, int $samples): GoogleMapsResultsCollection { |
|
99 | - |
|
100 | - if ((is_array($path) && count($path) < 2) || |
|
101 | - $path instanceof Path && $path->count() < 2) { |
|
102 | - throw new InvalidArgumentException('The number of items provided in the path must be greater than 1 (One)'); |
|
103 | - } |
|
104 | - |
|
105 | - if ($samples <= 0) { |
|
106 | - throw new InvalidArgumentException('The number of samples must be greater than 0 (Zero)'); |
|
107 | - } |
|
108 | - |
|
109 | - $path = $this->parseLocations($path); |
|
110 | - |
|
111 | - $request = $this->createRequest([ |
|
112 | - GoogleMapsRequestFields::PATH => $path, |
|
113 | - GoogleMapsRequestFields::SAMPLES => $samples, |
|
114 | - ]); |
|
115 | - |
|
116 | - return $this->getResultsCollections($request); |
|
117 | - } |
|
30 | + /** |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + const SERVICE_ENDPOINT = 'elevation'; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + protected $result_collection = ElevationResultsCollection::class; |
|
39 | + |
|
40 | + /** |
|
41 | + * Positional Requests |
|
42 | + * |
|
43 | + * @param LatLng|string|array $locations |
|
44 | + * This parameter takes either a single location or multiple locations passed as an array or as an encoded polyline |
|
45 | + * |
|
46 | + * @return GoogleMapsResultsCollection |
|
47 | + * |
|
48 | + * @since 0.3.0 |
|
49 | + */ |
|
50 | + public function getByLocations($locations): GoogleMapsResultsCollection { |
|
51 | + |
|
52 | + $locations = $this->parseLocations($locations); |
|
53 | + |
|
54 | + $request = $this->createRequest([ |
|
55 | + GoogleMapsRequestFields::LOCATIONS => $locations |
|
56 | + ]); |
|
57 | + |
|
58 | + return $this->getResultsCollections($request); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param array|string $locations |
|
63 | + * |
|
64 | + * @return string |
|
65 | + * |
|
66 | + * @since 0.3.0 |
|
67 | + */ |
|
68 | + public function parseLocations($locations): string { |
|
69 | + |
|
70 | + if($locations instanceof Path) { |
|
71 | + $locations = $locations->toArray(); |
|
72 | + } |
|
73 | + |
|
74 | + if (is_array($locations)) { |
|
75 | + $locations = implode('|', array_map(function ($item) { |
|
76 | + |
|
77 | + return (string)$item; |
|
78 | + }, $locations)); |
|
79 | + } |
|
80 | + |
|
81 | + return (string)$locations; |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * Sampled Path Requests |
|
86 | + * |
|
87 | + * @param array|string $path |
|
88 | + * This parameter takes either a multiple locations passed as an array or as an encoded polyline |
|
89 | + * |
|
90 | + * @param int $samples |
|
91 | + * This will be the number of results as well |
|
92 | + * |
|
93 | + * @throws InvalidArgumentException |
|
94 | + * @return GoogleMapsResultsCollection |
|
95 | + * |
|
96 | + * @since 0.4.0 |
|
97 | + */ |
|
98 | + public function getBySampledPath($path, int $samples): GoogleMapsResultsCollection { |
|
99 | + |
|
100 | + if ((is_array($path) && count($path) < 2) || |
|
101 | + $path instanceof Path && $path->count() < 2) { |
|
102 | + throw new InvalidArgumentException('The number of items provided in the path must be greater than 1 (One)'); |
|
103 | + } |
|
104 | + |
|
105 | + if ($samples <= 0) { |
|
106 | + throw new InvalidArgumentException('The number of samples must be greater than 0 (Zero)'); |
|
107 | + } |
|
108 | + |
|
109 | + $path = $this->parseLocations($path); |
|
110 | + |
|
111 | + $request = $this->createRequest([ |
|
112 | + GoogleMapsRequestFields::PATH => $path, |
|
113 | + GoogleMapsRequestFields::SAMPLES => $samples, |
|
114 | + ]); |
|
115 | + |
|
116 | + return $this->getResultsCollections($request); |
|
117 | + } |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -67,18 +67,18 @@ |
||
67 | 67 | */ |
68 | 68 | public function parseLocations($locations): string { |
69 | 69 | |
70 | - if($locations instanceof Path) { |
|
70 | + if ($locations instanceof Path) { |
|
71 | 71 | $locations = $locations->toArray(); |
72 | 72 | } |
73 | 73 | |
74 | 74 | if (is_array($locations)) { |
75 | - $locations = implode('|', array_map(function ($item) { |
|
75 | + $locations = implode('|', array_map(function($item) { |
|
76 | 76 | |
77 | - return (string)$item; |
|
77 | + return (string) $item; |
|
78 | 78 | }, $locations)); |
79 | 79 | } |
80 | 80 | |
81 | - return (string)$locations; |
|
81 | + return (string) $locations; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |