44
55class Pro6pp
66{
7-
87 private $ api_format = '' ;
98
109 private $ api_pretty = false ;
@@ -20,9 +19,10 @@ class Pro6pp
2019 *
2120 * @param $api_key
2221 * @param $format
23- * @param boolean $pretty
22+ * @param bool $pretty
2423 */
25- public function __construct ($ api_key , $ format = 'json ' , $ pretty = false ) {
24+ public function __construct ($ api_key , $ format = 'json ' , $ pretty = false )
25+ {
2626 $ this ->api_key = $ api_key ;
2727 $ this ->api_format = $ format ;
2828 $ this ->api_pretty = $ pretty ;
@@ -31,7 +31,8 @@ public function __construct($api_key, $format = 'json', $pretty = false) {
3131 /**
3232 * @return string
3333 */
34- public function getApikey () {
34+ public function getApikey ()
35+ {
3536 return $ this ->api_key ;
3637 }
3738
@@ -44,7 +45,8 @@ public function getApikey() {
4445 *
4546 * @return mixed
4647 */
47- public function autocomplete ($ postalcode , $ number = '' , $ extension = '' ) {
48+ public function autocomplete ($ postalcode , $ number = '' , $ extension = '' )
49+ {
4850 $ postalcode = $ this ->determinePostalType ($ postalcode );
4951
5052 $ this ->data = array_merge ($ postalcode , ['streetnumber ' => $ number , 'extension ' => $ extension ]);
@@ -60,7 +62,8 @@ public function autocomplete($postalcode, $number = '', $extension = '') {
6062 *
6163 * @return mixed
6264 */
63- public function reverse ($ lat , $ lng ) {
65+ public function reverse ($ lat , $ lng )
66+ {
6467 $ this ->data = ['lat ' => $ lat , 'lng ' => $ lng ];
6568
6669 return $ this ->call ('reverse ' , $ this ->prepareData ($ this ->data ));
@@ -75,8 +78,9 @@ public function reverse($lat, $lng) {
7578 *
7679 * @return mixed
7780 */
78- public function locator ($ target_nl_fourpps , $ optional = []) {
79- $ this ->data ['target_nl_fourpps ' ] = implode (", " , $ target_nl_fourpps );
81+ public function locator ($ target_nl_fourpps , $ optional = [])
82+ {
83+ $ this ->data ['target_nl_fourpps ' ] = implode (', ' , $ target_nl_fourpps );
8084
8185 $ this ->data = array_merge ($ this ->data , $ optional );
8286
@@ -93,21 +97,23 @@ public function locator($target_nl_fourpps, $optional = []) {
9397 *
9498 * @return mixed
9599 */
96- public function range ($ nl_fourpp , $ range = 5000 , $ per_page = 10 , $ page = 1 ) {
100+ public function range ($ nl_fourpp , $ range = 5000 , $ per_page = 10 , $ page = 1 )
101+ {
97102 $ this ->data = ['nl_fourpp ' => $ nl_fourpp , 'range ' => $ range , 'per_page ' => $ per_page , 'page ' => $ page ];
98103
99104 return $ this ->call ('range ' , $ this ->prepareData ($ this ->data ));
100105 }
101106
102107 /**
103- * Autocompletes a city name
108+ * Autocompletes a city name.
104109 *
105110 * @param $nl_city
106111 * @param int $per_page
107112 *
108113 * @return mixed
109114 */
110- public function suggest ($ nl_city , $ per_page = 10 ) {
115+ public function suggest ($ nl_city , $ per_page = 10 )
116+ {
111117 $ this ->data = ['nl_city ' => $ nl_city , 'per_page ' => $ per_page ];
112118
113119 return $ this ->call ('suggest ' , $ this ->prepareData ($ this ->data ));
@@ -123,7 +129,8 @@ public function suggest($nl_city, $per_page = 10) {
123129 *
124130 * @return mixed
125131 */
126- public function distance ($ from_nl_fourpp , $ to_nl_fourpp , $ algorithm = 'road ' ) {
132+ public function distance ($ from_nl_fourpp , $ to_nl_fourpp , $ algorithm = 'road ' )
133+ {
127134 $ this ->data = ['from_nl_fourpp ' => $ from_nl_fourpp , 'to_nl_fourpp ' => $ to_nl_fourpp , 'algorithm ' => $ algorithm ];
128135
129136 return $ this ->call ('distance ' , $ this ->prepareData ($ this ->data ));
@@ -136,7 +143,6 @@ public function distance($from_nl_fourpp, $to_nl_fourpp, $algorithm = 'road') {
136143 * @param $lng1
137144 * @param $lat2
138145 * @param $lng2
139- *
140146 * @param bool $miles
141147 *
142148 * @return float
@@ -157,26 +163,27 @@ public function coordinatesDistance($lat1, $lng1, $lat2, $lng2, $miles = false)
157163 $ c = 2 * atan2 (sqrt ($ a ), sqrt (1 - $ a ));
158164 $ km = $ r * $ c ;
159165
160- return ( $ miles ? ($ km * 0.621371192 ) : $ km) ;
166+ return $ miles ? ($ km * 0.621371192 ) : $ km ;
161167 }
162168
163169 /**
164170 * Checks if one of two valid postal types was sent along.
165171 *
166172 * @param $postalcode
167173 *
168- * @return array
169- *
170174 * @throws \Exception
175+ *
176+ * @return array
171177 */
172- public function determinePostalType ($ postalcode ) {
173- $ postalcode = str_replace (" " , "" , $ postalcode );
178+ public function determinePostalType ($ postalcode )
179+ {
180+ $ postalcode = str_replace (' ' , '' , $ postalcode );
174181
175- if (strlen ($ postalcode ) == 6 ) {
182+ if (strlen ($ postalcode ) == 6 ) {
176183 return ['nl_sixpp ' => $ postalcode ];
177184 }
178185
179- if (strlen ($ postalcode ) == 4 ) {
186+ if (strlen ($ postalcode ) == 4 ) {
180187 return ['nl_fourpp ' => $ postalcode ];
181188 }
182189
@@ -190,7 +197,8 @@ public function determinePostalType($postalcode) {
190197 *
191198 * @return mixed
192199 */
193- protected function prepareData ($ data ) {
200+ protected function prepareData ($ data )
201+ {
194202 $ data ['auth_key ' ] = $ this ->api_key ;
195203 $ data ['format ' ] = $ this ->api_format ;
196204 $ data ['pretty ' ] = $ this ->api_pretty ;
@@ -207,8 +215,9 @@ protected function prepareData($data) {
207215 *
208216 * @return mixed
209217 */
210- protected function call ($ path , $ data ) {
211- $ url = $ this ->api_host . $ path .'? ' . http_build_query ($ data );
218+ protected function call ($ path , $ data )
219+ {
220+ $ url = $ this ->api_host .$ path .'? ' .http_build_query ($ data );
212221
213222 $ ch = curl_init ($ url );
214223
@@ -221,5 +230,4 @@ protected function call($path, $data) {
221230
222231 return $ return ;
223232 }
224-
225233}
0 commit comments