@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | return $route; |
96 | 96 | } |
97 | 97 | |
98 | - public static function getRoutes($routeId=null, $params=null) |
|
98 | + public static function getRoutes($routeId = null, $params = null) |
|
99 | 99 | { |
100 | 100 | $result = Route4Me::makeRequst(array( |
101 | 101 | 'url' => Endpoint::ROUTE_V4, |
102 | 102 | 'method' => 'GET', |
103 | 103 | 'query' => array( |
104 | 104 | 'api_key' => Route4Me::getApiKey(), |
105 | - 'route_id' => !is_null($routeId) ? implode(',', (array) $routeId) : null, |
|
105 | + 'route_id' => !is_null($routeId) ? implode(',', (array)$routeId) : null, |
|
106 | 106 | 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
107 | 107 | 'query' => isset($params['query']) ? $params['query'] : null, |
108 | 108 | 'directions' => isset($params['directions']) ? $params['directions'] : null, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return Route::fromArray($result); die(""); |
117 | 117 | } else { |
118 | 118 | $routes = array(); |
119 | - foreach($result as $route) { |
|
119 | + foreach ($result as $route) { |
|
120 | 120 | $routes[] = Route::fromArray($route); |
121 | 121 | } |
122 | 122 | return $routes; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | // Returns random route_id from existing routes between $offset and $offset+$limit |
233 | - public function getRandomRouteId($offset,$limit) |
|
233 | + public function getRandomRouteId($offset, $limit) |
|
234 | 234 | { |
235 | 235 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
236 | 236 | $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | if (sizeof($json)>0) { |
245 | 245 | $routes = array(); |
246 | 246 | |
247 | - foreach($json as $route) { |
|
247 | + foreach ($json as $route) { |
|
248 | 248 | $routes[] = Route::fromArray($route); |
249 | 249 | } |
250 | 250 | |
251 | - $num=rand(0,sizeof($routes)-1); |
|
252 | - $rRoute=(array)$routes[$num]; |
|
251 | + $num = rand(0, sizeof($routes) - 1); |
|
252 | + $rRoute = (array)$routes[$num]; |
|
253 | 253 | |
254 | 254 | if (is_array($rRoute)) { |
255 | 255 | return $rRoute["route_id"]; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | 'query' => array( |
271 | 271 | 'route_id' => isset($this->route_id) ? $this->route_id : null |
272 | 272 | ), |
273 | - 'body' => array ( |
|
273 | + 'body' => array( |
|
274 | 274 | 'parameters' => $this->parameters, |
275 | 275 | ), |
276 | 276 | 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | return Route::fromArray($route); |
280 | 280 | } |
281 | 281 | |
282 | - public function updateAddress($address=null) |
|
282 | + public function updateAddress($address = null) |
|
283 | 283 | { |
284 | 284 | $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
285 | 285 | : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
359 | 359 | $rpath = realpath($fname); |
360 | 360 | |
361 | - $result= Route4Me::makeRequst(array( |
|
361 | + $result = Route4Me::makeRequst(array( |
|
362 | 362 | 'url' => Endpoint::ROUTE_NOTES_ADD, |
363 | 363 | 'method' => 'POST', |
364 | 364 | 'query' => array( |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | $result = Route4Me::makeRequst(array( |
391 | 391 | 'url' => Endpoint::ROUTE_V4, |
392 | 392 | 'method' => 'DELETE', |
393 | - 'query' => array( 'route_id' => $route_id ) |
|
393 | + 'query' => array('route_id' => $route_id) |
|
394 | 394 | )); |
395 | 395 | |
396 | 396 | $result = Route4Me::makeRequst(array( |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | |
408 | 408 | public function GetAddressesFromRoute($route_id) |
409 | 409 | { |
410 | - $route1=Route::getRoutes($route_id,null); |
|
410 | + $route1 = Route::getRoutes($route_id, null); |
|
411 | 411 | if (isset($route1)) { |
412 | 412 | return $route1->addresses; |
413 | 413 | } else { |
@@ -417,12 +417,12 @@ discard block |
||
417 | 417 | |
418 | 418 | public function GetRandomAddressFromRoute($route_id) |
419 | 419 | { |
420 | - $route1 = Route::getRoutes($route_id,null); |
|
420 | + $route1 = Route::getRoutes($route_id, null); |
|
421 | 421 | |
422 | 422 | if (isset($route1)) { |
423 | 423 | $addresses = $route1->addresses; |
424 | 424 | |
425 | - $rnd = rand(0,sizeof($addresses)-1); |
|
425 | + $rnd = rand(0, sizeof($addresses) - 1); |
|
426 | 426 | |
427 | 427 | return $addresses[$rnd]; |
428 | 428 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $addressbooklocation = new AddressBookLocation(); |
55 | 55 | |
56 | - foreach($params as $key => $value) { |
|
56 | + foreach ($params as $key => $value) { |
|
57 | 57 | if (property_exists($addressbooklocation, $key)) { |
58 | 58 | $addressbooklocation->{$key} = $value; |
59 | 59 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | public static function searchRoutedLocation($params) |
80 | 80 | { |
81 | - $result= Route4Me::makeRequst(array( |
|
81 | + $result = Route4Me::makeRequst(array( |
|
82 | 82 | 'url' => Endpoint::ADDRESS_BOOK_V4, |
83 | 83 | 'method' => 'GET', |
84 | 84 | 'query' => array( |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | if (isset($ablocations["results"])) { |
135 | 135 | $locationsSize = sizeof($ablocations["results"]); |
136 | 136 | |
137 | - if ($locationsSize > 0) { |
|
137 | + if ($locationsSize>0) { |
|
138 | 138 | $randomLocationIndex = rand(0, $locationsSize - 1); |
139 | 139 | return $ablocations["results"][$randomLocationIndex]; |
140 | 140 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | $body = array(); |
149 | 149 | $abLocations = new AddressBookLocation(); |
150 | 150 | |
151 | - foreach($params as $key => $value) { |
|
152 | - if ($key == "address_id") continue; |
|
151 | + foreach ($params as $key => $value) { |
|
152 | + if ($key=="address_id") continue; |
|
153 | 153 | if (property_exists($abLocations, $key)) { |
154 | 154 | if (isset($params->{$key})) { |
155 | 155 | $body[$key] = $params->{$key}; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $body = array(); |
185 | 185 | $abLocations = new AddressBookLocation(); |
186 | 186 | |
187 | - foreach($params as $key => $value) { |
|
187 | + foreach ($params as $key => $value) { |
|
188 | 188 | if (property_exists($abLocations, $key)) { |
189 | 189 | if (isset($params->{$key})) { |
190 | 190 | $body[$key] = $params->{$key}; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | public static function validateScheduleMode($scheduleMode) |
221 | 221 | { |
222 | - $schedMmodes = array("daily","weekly","monthly","annually"); |
|
222 | + $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
223 | 223 | |
224 | 224 | if (in_array($scheduleMode, $schedMmodes)) |
225 | 225 | return TRUE; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | public static function validateScheduleEnable($scheduleEnabled) |
231 | 231 | { |
232 | - $schedEnambles = array(TRUE,FALSE); |
|
232 | + $schedEnambles = array(TRUE, FALSE); |
|
233 | 233 | |
234 | 234 | if (in_array($scheduleEnabled, $schedEnambles)) |
235 | 235 | return TRUE; |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | { |
250 | 250 | $weekdays = explode(',', $scheduleWeekDays); |
251 | 251 | |
252 | - if (sizeof($weekdays) < 1) return FALSE; |
|
252 | + if (sizeof($weekdays)<1) return FALSE; |
|
253 | 253 | |
254 | 254 | $isValid = TRUE; |
255 | 255 | |
256 | - for ($i=0; $i < sizeof($weekdays); $i++) { |
|
256 | + for ($i = 0; $i<sizeof($weekdays); $i++) { |
|
257 | 257 | if (is_numeric($weekdays[$i])) { |
258 | 258 | $wday = intval($weekdays[$i]); |
259 | - if ($wday < 1 || $wday > 7) $isValid = FALSE; |
|
259 | + if ($wday<1 || $wday>7) $isValid = FALSE; |
|
260 | 260 | } |
261 | 261 | else $isValid = FALSE; |
262 | 262 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
268 | 268 | { |
269 | - $schedMonthlyMmodes = array("dates","nth"); |
|
269 | + $schedMonthlyMmodes = array("dates", "nth"); |
|
270 | 270 | |
271 | 271 | if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) |
272 | 272 | return TRUE; |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | { |
279 | 279 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
280 | 280 | |
281 | - if (sizeof($monthlyDates) <1) return FALSE; |
|
281 | + if (sizeof($monthlyDates)<1) return FALSE; |
|
282 | 282 | |
283 | 283 | $isValid = TRUE; |
284 | 284 | |
285 | - for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
285 | + for ($i = 0; $i<sizeof($monthlyDates); $i++) { |
|
286 | 286 | if (is_numeric($monthlyDates[$i])) { |
287 | 287 | $mday = intval($monthlyDates[$i]); |
288 | - if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
288 | + if ($mday<1 || $mday>31) $isValid = FALSE; |
|
289 | 289 | } |
290 | 290 | else $isValid = FALSE; |
291 | 291 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | { |
298 | 298 | if (!is_numeric($scheduleNthN)) return FALSE; |
299 | 299 | |
300 | - $schedNthNs = array(1,2,3,4,5,-1); |
|
300 | + $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
301 | 301 | |
302 | 302 | if (in_array($scheduleNthN, $schedNthNs)) |
303 | 303 | return TRUE; |
@@ -333,17 +333,17 @@ discard block |
||
333 | 333 | $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
334 | 334 | |
335 | 335 | if (empty($columns)) { |
336 | - array_push($results['fail'],'Empty CSV table'); |
|
336 | + array_push($results['fail'], 'Empty CSV table'); |
|
337 | 337 | return ($results); |
338 | 338 | } |
339 | 339 | |
340 | 340 | $iRow = 1; |
341 | 341 | |
342 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
342 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
343 | 343 | if ($rows[$locationsFieldsMapping['cached_lat']] |
344 | 344 | && $rows[$locationsFieldsMapping['cached_lng']] |
345 | 345 | && $rows[$locationsFieldsMapping['address_1']] |
346 | - && array(null) !== $rows) { |
|
346 | + && array(null)!==$rows) { |
|
347 | 347 | $curSchedule = ""; |
348 | 348 | $mode = ""; |
349 | 349 | |
@@ -352,32 +352,32 @@ discard block |
||
352 | 352 | $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
353 | 353 | $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
354 | 354 | } else { |
355 | - array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); |
|
355 | + array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
356 | 356 | $curSchedule = ""; |
357 | 357 | } |
358 | 358 | } else { |
359 | - array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); |
|
359 | + array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
360 | 360 | $curSchedule = ""; |
361 | 361 | } |
362 | 362 | |
363 | 363 | if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
364 | 364 | if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
365 | - $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
365 | + $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
366 | 366 | } else { |
367 | - array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); |
|
367 | + array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
368 | 368 | $curSchedule = ""; |
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | 372 | if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
373 | 373 | if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
374 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
375 | - if ($mode == 'daily') { |
|
376 | - $curSchedule = trim($curSchedule,','); |
|
377 | - $curSchedule.='}'; |
|
374 | + $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
375 | + if ($mode=='daily') { |
|
376 | + $curSchedule = trim($curSchedule, ','); |
|
377 | + $curSchedule .= '}'; |
|
378 | 378 | } |
379 | 379 | } else { |
380 | - array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); |
|
380 | + array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
381 | 381 | $curSchedule = ""; |
382 | 382 | } |
383 | 383 | } |
@@ -387,13 +387,13 @@ discard block |
||
387 | 387 | case 'weekly': |
388 | 388 | if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
389 | 389 | if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
390 | - $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
390 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
391 | 391 | } else { |
392 | - array_push($results['fail'],"$iRow --> Wrong weekdays"); |
|
392 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
393 | 393 | $curSchedule = ""; |
394 | 394 | } |
395 | 395 | } else { |
396 | - array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); |
|
396 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
397 | 397 | $curSchedule = ""; |
398 | 398 | } |
399 | 399 | break; |
@@ -402,24 +402,24 @@ discard block |
||
402 | 402 | if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
403 | 403 | if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
404 | 404 | $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
405 | - $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
405 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
406 | 406 | } else { |
407 | - array_push($results['fail'],"$iRow --> Wrong monthly mode"); |
|
407 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
408 | 408 | $curSchedule = ""; |
409 | 409 | } |
410 | 410 | } else { |
411 | - array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); |
|
411 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
412 | 412 | $curSchedule = ""; |
413 | 413 | } |
414 | 414 | |
415 | - if ($monthlyMode != "") { |
|
415 | + if ($monthlyMode!="") { |
|
416 | 416 | switch ($monthlyMode) { |
417 | 417 | case 'dates': |
418 | 418 | if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
419 | 419 | if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
420 | - $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
420 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
421 | 421 | } else { |
422 | - array_push($results['fail'],"$iRow --> Wrong monthly dates"); |
|
422 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
423 | 423 | $curSchedule = ""; |
424 | 424 | } |
425 | 425 | } |
@@ -427,26 +427,26 @@ discard block |
||
427 | 427 | case 'nth': |
428 | 428 | if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
429 | 429 | if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
430 | - $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
430 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
431 | 431 | } else { |
432 | - array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); |
|
432 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
433 | 433 | $curSchedule = ""; |
434 | 434 | } |
435 | 435 | } else { |
436 | - array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); |
|
436 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
437 | 437 | $curSchedule = ""; |
438 | 438 | } |
439 | 439 | |
440 | - if ($curSchedule != "") { |
|
440 | + if ($curSchedule!="") { |
|
441 | 441 | if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
442 | 442 | if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
443 | - $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
443 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
444 | 444 | } else { |
445 | - array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); |
|
445 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
446 | 446 | $curSchedule = ""; |
447 | 447 | } |
448 | 448 | } else { |
449 | - array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); |
|
449 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
450 | 450 | $curSchedule = ""; |
451 | 451 | } |
452 | 452 | } |
@@ -460,16 +460,16 @@ discard block |
||
460 | 460 | } |
461 | 461 | } |
462 | 462 | |
463 | - if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") { |
|
463 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
464 | 464 | $iRow++; |
465 | 465 | continue; |
466 | 466 | } |
467 | 467 | |
468 | - $curSchedule =strtolower($curSchedule); |
|
468 | + $curSchedule = strtolower($curSchedule); |
|
469 | 469 | |
470 | 470 | $curSchedule = '[{'.$curSchedule.'}]'; |
471 | 471 | |
472 | - $oSchedule = json_decode($curSchedule,TRUE); |
|
472 | + $oSchedule = json_decode($curSchedule, TRUE); |
|
473 | 473 | |
474 | 474 | $AdressBookLocationParameters = AddressBookLocation::fromArray(array( |
475 | 475 | "cached_lat" => $rows[$locationsFieldsMapping['cached_lat']], |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | |
545 | 545 | $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
546 | 546 | |
547 | - array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
547 | + array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
548 | 548 | } |
549 | 549 | } |
550 | 550 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
35 | 35 | } |
36 | 36 | |
37 | - foreach($params['addresses'] as $address) { |
|
37 | + foreach ($params['addresses'] as $address) { |
|
38 | 38 | if (!($address instanceof Address)) { |
39 | 39 | $address = Address::fromArray($address); |
40 | 40 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $addresses = array(); |
79 | 79 | |
80 | - foreach($this->addresses as $address) { |
|
80 | + foreach ($this->addresses as $address) { |
|
81 | 81 | $addresses[] = $address->toArray(); |
82 | 82 | } |
83 | 83 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return MyQ |
46 | 46 | */ |
47 | - public function __construct ($params = array()) |
|
47 | + public function __construct($params = array()) |
|
48 | 48 | { |
49 | 49 | // Overwrite class variables |
50 | 50 | foreach ($params as $k => $v) { |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | // Initialize cURL request headers |
55 | - if (sizeof($this->_headers) == 0) { |
|
56 | - $this->_headers = array ( |
|
55 | + if (sizeof($this->_headers)==0) { |
|
56 | + $this->_headers = array( |
|
57 | 57 | 'MyQApplicationId' => $this->appId, |
58 | 58 | 'Culture' => $this->culture, |
59 | 59 | 'Content-Type' => $this->contentType, |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return MyQ |
77 | 77 | */ |
78 | - public function login ($username = null, $password = null) |
|
78 | + public function login($username = null, $password = null) |
|
79 | 79 | { |
80 | 80 | // Set username/password if not null |
81 | 81 | if (!is_null($username)) { |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | $error[] = 'password'; |
97 | 97 | } |
98 | 98 | |
99 | - if (sizeof($error) > 0) { |
|
100 | - throw new MyQException('Missing required auth credential: ' . implode(',', $error)); |
|
99 | + if (sizeof($error)>0) { |
|
100 | + throw new MyQException('Missing required auth credential: '.implode(',', $error)); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $this->_login(); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $this->_getDetails(); |
109 | 109 | $timeInState = time() - $this->_doorStateTime; |
110 | - echo implode(',', array ( |
|
110 | + echo implode(',', array( |
|
111 | 111 | $this->_locationName, |
112 | 112 | $this->_doorName, |
113 | 113 | $this->_doorState, |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | if (!isset($this->_conn)) { |
126 | 126 | $this->_conn = curl_init(); |
127 | 127 | |
128 | - curl_setopt_array($this->_conn, array ( |
|
128 | + curl_setopt_array($this->_conn, array( |
|
129 | 129 | CURLOPT_RETURNTRANSFER => true, |
130 | 130 | CURLOPT_ENCODING => "", |
131 | 131 | CURLOPT_MAXREDIRS => 10, |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | $data = json_decode($output); |
169 | 169 | |
170 | - if ($data == false || !isset($data->SecurityToken)) { |
|
170 | + if ($data==false || !isset($data->SecurityToken)) { |
|
171 | 171 | throw new MyQException("Error processing login request: $output"); |
172 | 172 | } |
173 | 173 | |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | |
188 | 188 | $data = json_decode($output); |
189 | 189 | |
190 | - if ($data == false || !isset($data->Devices)) { |
|
190 | + if ($data==false || !isset($data->Devices)) { |
|
191 | 191 | throw new MyQException("Error fetching device details: $output"); |
192 | 192 | } |
193 | 193 | |
194 | 194 | // Find our door device ID |
195 | 195 | foreach ($data->Devices as $device) { |
196 | - if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) { |
|
196 | + if (stripos($device->MyQDeviceTypeName, "Gateway")!==false) { |
|
197 | 197 | // Find location name |
198 | 198 | foreach ($device->Attributes as $attr) { |
199 | - if ($attr->AttributeDisplayName == 'desc') { |
|
199 | + if ($attr->AttributeDisplayName=='desc') { |
|
200 | 200 | $this->_locationName = $attr->Value; |
201 | 201 | } |
202 | 202 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | }*/ |
79 | 79 | |
80 | 80 | $address = new Address(); |
81 | - foreach($params as $key => $value) { |
|
81 | + foreach ($params as $key => $value) { |
|
82 | 82 | if (property_exists($address, $key)) { |
83 | 83 | $address->{$key} = $value; |
84 | 84 | } |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | 'url' => Endpoint::MARK_ADDRESS_DEPARTED, |
157 | 157 | 'method' => 'GET', |
158 | 158 | 'query' => array( |
159 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
160 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
161 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
162 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
159 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
160 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
161 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed'] : null, |
|
162 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
163 | 163 | ), |
164 | 164 | )); |
165 | 165 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | foreach ($params as $key => $value) { |
304 | 304 | $kpos = strpos($key, "custom_note_type"); |
305 | 305 | |
306 | - if ($kpos !== false) { |
|
307 | - $customArray[$key]=$value; |
|
306 | + if ($kpos!==false) { |
|
307 | + $customArray[$key] = $value; |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | class CurlHttpClient |
5 | 5 | { |
6 | - var $ch ; |
|
6 | + var $ch; |
|
7 | 7 | var $debug = false; |
8 | 8 | var $error_msg; |
9 | 9 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | //set error in case http return code bigger than 300 |
22 | 22 | curl_setopt($this->ch, CURLOPT_FAILONERROR, true); |
23 | 23 | // use gzip if possible |
24 | - curl_setopt($this->ch,CURLOPT_ENCODING , 'gzip, deflate'); |
|
24 | + curl_setopt($this->ch, CURLOPT_ENCODING, 'gzip, deflate'); |
|
25 | 25 | // do not veryfy ssl |
26 | 26 | // this is important for windows |
27 | 27 | // as well for being able to access pages with non valid cert |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string pass |
35 | 35 | * @access public |
36 | 36 | */ |
37 | - function setCredentials($username,$password) |
|
37 | + function setCredentials($username, $password) |
|
38 | 38 | { |
39 | 39 | curl_setopt($this->ch, CURLOPT_USERPWD, "$username:$password"); |
40 | 40 | } |
@@ -89,21 +89,21 @@ discard block |
||
89 | 89 | * @return string data |
90 | 90 | * @access public |
91 | 91 | */ |
92 | - function sendPostData($url, $postdata, $ip=null, $timeout=10) |
|
92 | + function sendPostData($url, $postdata, $ip = null, $timeout = 10) |
|
93 | 93 | { |
94 | 94 | //set various curl options first |
95 | 95 | // set url to post to |
96 | - curl_setopt($this->ch, CURLOPT_URL,$url); |
|
96 | + curl_setopt($this->ch, CURLOPT_URL, $url); |
|
97 | 97 | // return into a variable rather than displaying it |
98 | - curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,true); |
|
98 | + curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); |
|
99 | 99 | |
100 | 100 | //bind to specific ip address if it is sent trough arguments |
101 | - if($ip) { |
|
102 | - if($this->debug) |
|
101 | + if ($ip) { |
|
102 | + if ($this->debug) |
|
103 | 103 | { |
104 | 104 | echo "Binding to ip $ip\n"; |
105 | 105 | } |
106 | - curl_setopt($this->ch,CURLOPT_INTERFACE,$ip); |
|
106 | + curl_setopt($this->ch, CURLOPT_INTERFACE, $ip); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //set curl function timeout to $timeout |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | |
117 | 117 | //and finally send curl request |
118 | 118 | $result = curl_exec_redir($this->ch); |
119 | - if(curl_errno($this->ch)) { |
|
120 | - if($this->debug) { |
|
119 | + if (curl_errno($this->ch)) { |
|
120 | + if ($this->debug) { |
|
121 | 121 | echo "Error Occured in Curl\n"; |
122 | - echo "Error number: " .curl_errno($this->ch) ."\n"; |
|
123 | - echo "Error message: " .curl_error($this->ch)."\n"; |
|
122 | + echo "Error number: ".curl_errno($this->ch)."\n"; |
|
123 | + echo "Error message: ".curl_error($this->ch)."\n"; |
|
124 | 124 | } |
125 | 125 | return false; |
126 | 126 | } else { |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | * @return string data |
138 | 138 | * @access public |
139 | 139 | */ |
140 | - function fetchUrl($url, $ip=null, $timeout=5) |
|
140 | + function fetchUrl($url, $ip = null, $timeout = 5) |
|
141 | 141 | { |
142 | 142 | // set url to post to |
143 | - curl_setopt($this->ch, CURLOPT_URL,$url); |
|
143 | + curl_setopt($this->ch, CURLOPT_URL, $url); |
|
144 | 144 | |
145 | 145 | //set method to get |
146 | - curl_setopt($this->ch, CURLOPT_HTTPGET,true); |
|
146 | + curl_setopt($this->ch, CURLOPT_HTTPGET, true); |
|
147 | 147 | // return into a variable rather than displaying it |
148 | - curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,true); |
|
148 | + curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); |
|
149 | 149 | |
150 | 150 | //bind to specific ip address if it is sent trough arguments |
151 | - if($ip) { |
|
152 | - if($this->debug) { |
|
151 | + if ($ip) { |
|
152 | + if ($this->debug) { |
|
153 | 153 | echo "Binding to ip $ip\n"; |
154 | 154 | } |
155 | 155 | |
156 | - curl_setopt($this->ch,CURLOPT_INTERFACE,$ip); |
|
156 | + curl_setopt($this->ch, CURLOPT_INTERFACE, $ip); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | //set curl function timeout to $timeout |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | |
162 | 162 | //and finally send curl request |
163 | 163 | $result = curl_exec_redir($this->ch); |
164 | - if(curl_errno($this->ch)) { |
|
165 | - if($this->debug) { |
|
164 | + if (curl_errno($this->ch)) { |
|
165 | + if ($this->debug) { |
|
166 | 166 | echo "Error Occured in Curl\n"; |
167 | - echo "Error number: " .curl_errno($this->ch) ."\n"; |
|
168 | - echo "Error message: " .curl_error($this->ch)."\n"; |
|
167 | + echo "Error number: ".curl_errno($this->ch)."\n"; |
|
168 | + echo "Error message: ".curl_error($this->ch)."\n"; |
|
169 | 169 | } |
170 | 170 | return false; |
171 | 171 | } else { |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | * @return boolean true on success false othervise |
184 | 184 | * @access public |
185 | 185 | */ |
186 | - function fetchIntoFile($url, $fp, $ip=null, $timeout=5) |
|
186 | + function fetchIntoFile($url, $fp, $ip = null, $timeout = 5) |
|
187 | 187 | { |
188 | 188 | // set url to post to |
189 | - curl_setopt($this->ch, CURLOPT_URL,$url); |
|
189 | + curl_setopt($this->ch, CURLOPT_URL, $url); |
|
190 | 190 | //set method to get |
191 | 191 | curl_setopt($this->ch, CURLOPT_HTTPGET, true); |
192 | 192 | // store data into file rather than displaying it |
193 | 193 | curl_setopt($this->ch, CURLOPT_FILE, $fp); |
194 | 194 | |
195 | 195 | //bind to specific ip address if it is sent trough arguments |
196 | - if($ip) { |
|
197 | - if($this->debug) { |
|
196 | + if ($ip) { |
|
197 | + if ($this->debug) { |
|
198 | 198 | echo "Binding to ip $ip\n"; |
199 | 199 | } |
200 | 200 | curl_setopt($this->ch, CURLOPT_INTERFACE, $ip); |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | |
206 | 206 | //and finally send curl request |
207 | 207 | $result = curl_exec_redir($this->ch); |
208 | - if(curl_errno($this->ch)) { |
|
209 | - if($this->debug) { |
|
208 | + if (curl_errno($this->ch)) { |
|
209 | + if ($this->debug) { |
|
210 | 210 | echo "Error Occured in Curl\n"; |
211 | - echo "Error number: " .curl_errno($this->ch) ."\n"; |
|
212 | - echo "Error message: " .curl_error($this->ch)."\n"; |
|
211 | + echo "Error number: ".curl_errno($this->ch)."\n"; |
|
212 | + echo "Error message: ".curl_error($this->ch)."\n"; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | return false; |
216 | - } else { |
|
216 | + } else { |
|
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @return string data |
231 | 231 | * @access public |
232 | 232 | */ |
233 | - function sendMultipartPostData($url, $postdata, $file_field_array=array(), $ip=null, $timeout=30) |
|
233 | + function sendMultipartPostData($url, $postdata, $file_field_array = array(), $ip = null, $timeout = 30) |
|
234 | 234 | { |
235 | 235 | //set various curl options first |
236 | 236 | // set url to post to |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); |
240 | 240 | |
241 | 241 | //bind to specific ip address if it is sent trough arguments |
242 | - if($ip) { |
|
243 | - if($this->debug) { |
|
242 | + if ($ip) { |
|
243 | + if ($this->debug) { |
|
244 | 244 | echo "Binding to ip $ip\n"; |
245 | 245 | } |
246 | 246 | |
247 | - curl_setopt($this->ch,CURLOPT_INTERFACE,$ip); |
|
247 | + curl_setopt($this->ch, CURLOPT_INTERFACE, $ip); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | //set curl function timeout to $timeout |
@@ -261,26 +261,26 @@ discard block |
||
261 | 261 | $post_array = array(); |
262 | 262 | $post_string_array = array(); |
263 | 263 | |
264 | - if(!is_array($postdata)) { |
|
264 | + if (!is_array($postdata)) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - foreach($postdata as $key=>$value) { |
|
268 | + foreach ($postdata as $key=>$value) { |
|
269 | 269 | $post_array[$key] = $value; |
270 | 270 | $post_string_array[] = urlencode($key)."=".urlencode($value); |
271 | 271 | } |
272 | 272 | |
273 | - $post_string = implode("&",$post_string_array); |
|
274 | - if($this->debug) { |
|
273 | + $post_string = implode("&", $post_string_array); |
|
274 | + if ($this->debug) { |
|
275 | 275 | echo "Post String: $post_string\n"; |
276 | 276 | } |
277 | 277 | |
278 | 278 | // set post string |
279 | 279 | //curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_string); |
280 | 280 | // set multipart form data - file array field-value pairs |
281 | - if(!empty($file_field_array)) { |
|
282 | - foreach($file_field_array as $var_name => $var_value) { |
|
283 | - if(strpos(PHP_OS, "WIN") !== false) $var_value = str_replace("/", "\\", $var_value); // win hack |
|
281 | + if (!empty($file_field_array)) { |
|
282 | + foreach ($file_field_array as $var_name => $var_value) { |
|
283 | + if (strpos(PHP_OS, "WIN")!==false) $var_value = str_replace("/", "\\", $var_value); // win hack |
|
284 | 284 | $file_field_array[$var_name] = "@".$var_value; |
285 | 285 | } |
286 | 286 | } |
@@ -291,11 +291,11 @@ discard block |
||
291 | 291 | |
292 | 292 | //and finally send curl request |
293 | 293 | $result = curl_exec_redir($this->ch); |
294 | - if(curl_errno($this->ch)) { |
|
295 | - if($this->debug) { |
|
294 | + if (curl_errno($this->ch)) { |
|
295 | + if ($this->debug) { |
|
296 | 296 | echo "Error Occured in Curl\n"; |
297 | - echo "Error number: " .curl_errno($this->ch) ."\n"; |
|
298 | - echo "Error message: " .curl_error($this->ch)."\n"; |
|
297 | + echo "Error number: ".curl_errno($this->ch)."\n"; |
|
298 | + echo "Error message: ".curl_error($this->ch)."\n"; |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | return false; |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | function storeCookies($cookie_file) |
313 | 313 | { |
314 | 314 | // use cookies on each request (cookies stored in $cookie_file) |
315 | - curl_setopt ($this->ch, CURLOPT_COOKIEJAR, $cookie_file); |
|
316 | - curl_setopt ($this->ch, CURLOPT_COOKIEFILE, $cookie_file); |
|
315 | + curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookie_file); |
|
316 | + curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookie_file); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | */ |
324 | 324 | function setCookie($cookie) |
325 | 325 | { |
326 | - curl_setopt ($this->ch, CURLOPT_COOKIE, $cookie); |
|
326 | + curl_setopt($this->ch, CURLOPT_COOKIE, $cookie); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | */ |
355 | 355 | function getErrorMsg() |
356 | 356 | { |
357 | - $err = "Error number: " .curl_errno($this->ch) ."\n"; |
|
358 | - $err .="Error message: " .curl_error($this->ch)."\n"; |
|
357 | + $err = "Error number: ".curl_errno($this->ch)."\n"; |
|
358 | + $err .= "Error message: ".curl_error($this->ch)."\n"; |
|
359 | 359 | return $err; |
360 | 360 | } |
361 | 361 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | static $curl_loops = 0; |
382 | 382 | static $curl_max_loops = 20; |
383 | 383 | |
384 | - if ($curl_loops++ >= $curl_max_loops) { |
|
384 | + if ($curl_loops++>=$curl_max_loops) { |
|
385 | 385 | $curl_loops = 0; |
386 | 386 | return FALSE; |
387 | 387 | } |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | //echo "*** Got HTTP code: $http_code ***\n"; |
399 | 399 | //echo "** Got headers: \n$header\n\n"; |
400 | 400 | |
401 | - if ( $http_code == 301 || $http_code == 302 ) { |
|
401 | + if ($http_code==301 || $http_code==302) { |
|
402 | 402 | // If we're redirected, we should revert to GET |
403 | - curl_setopt($ch, CURLOPT_HTTPGET,true); |
|
403 | + curl_setopt($ch, CURLOPT_HTTPGET, true); |
|
404 | 404 | |
405 | 405 | $matches = array(); |
406 | 406 | preg_match('/Location:\s*(.*?)(\n|$)/i', $header, $matches); |
@@ -422,13 +422,13 @@ discard block |
||
422 | 422 | if (empty($url['path'])) |
423 | 423 | $url['path'] = $last_url['path']; |
424 | 424 | |
425 | - $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:''); |
|
425 | + $new_url = $url['scheme'].'://'.$url['host'].$url['path'].(!empty($url['query']) ? '?'.$url['query'] : ''); |
|
426 | 426 | //echo "Being redirected to $new_url\n"; |
427 | 427 | curl_setopt($ch, CURLOPT_URL, $new_url); |
428 | 428 | |
429 | 429 | return curl_exec_redir($ch); |
430 | 430 | } else { |
431 | - $curl_loops=0; |
|
431 | + $curl_loops = 0; |
|
432 | 432 | return $data; |
433 | 433 | } |
434 | 434 | } |
@@ -44,18 +44,18 @@ |
||
44 | 44 | const ORDER_V4 = '/api.v4/order.php'; |
45 | 45 | |
46 | 46 | const ROUTE_V4 = '/api.v4/route.php'; |
47 | - const ROUTE_DUPLICATE ='/actions/duplicate_route.php'; |
|
48 | - const ROUTES_DELETE ='/actions/delete_routes.php'; |
|
49 | - const REOPTIMIZE_V3_2 ='/api.v3/route/reoptimize_2.php'; |
|
50 | - const ROUTES_MERGE ='/actions/merge_routes.php'; |
|
51 | - const ROUTE_SHARE ='/actions/route/share_route.php'; |
|
52 | - const ROUTE_NOTES_ADD ='/actions/addRouteNotes.php'; |
|
53 | - const STATUS_V4 ='/api.v4/status.php'; |
|
54 | - const GET_DEVICE_LOCATION ='/api/track/get_device_location.php'; |
|
55 | - |
|
56 | - const TRACK_SET ='/track/set.php'; |
|
57 | - |
|
58 | - const NOTE_CUSTOM_TYPES_V4 ='/api.v4/note_custom_types.php'; |
|
47 | + const ROUTE_DUPLICATE = '/actions/duplicate_route.php'; |
|
48 | + const ROUTES_DELETE = '/actions/delete_routes.php'; |
|
49 | + const REOPTIMIZE_V3_2 = '/api.v3/route/reoptimize_2.php'; |
|
50 | + const ROUTES_MERGE = '/actions/merge_routes.php'; |
|
51 | + const ROUTE_SHARE = '/actions/route/share_route.php'; |
|
52 | + const ROUTE_NOTES_ADD = '/actions/addRouteNotes.php'; |
|
53 | + const STATUS_V4 = '/api.v4/status.php'; |
|
54 | + const GET_DEVICE_LOCATION = '/api/track/get_device_location.php'; |
|
55 | + |
|
56 | + const TRACK_SET = '/track/set.php'; |
|
57 | + |
|
58 | + const NOTE_CUSTOM_TYPES_V4 = '/api.v4/note_custom_types.php'; |
|
59 | 59 | |
60 | 60 | const VEHICLE_V4 = '/api/vehicles'; |
61 | 61 | } |
@@ -10,6 +10,6 @@ |
||
10 | 10 | const TSP_TW = 5; |
11 | 11 | const TSP_TW_CR = 6; |
12 | 12 | const BBCVRP = 7; |
13 | - const ALG_NONE = 100; |
|
13 | + const ALG_NONE = 100; |
|
14 | 14 | const ALG_LEGACY_DISTRIBUTED = 101; |
15 | 15 | } |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | public $weight_metric; |
60 | 60 | public $max_weight_per_axle_group_metric; |
61 | 61 | |
62 | - public function __construct () |
|
62 | + public function __construct() |
|
63 | 63 | { |
64 | 64 | Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
65 | 65 | } |
66 | 66 | |
67 | 67 | public static function fromArray(array $params) { |
68 | - $vehicle= new Vehicle(); |
|
69 | - foreach($params as $key => $value) { |
|
68 | + $vehicle = new Vehicle(); |
|
69 | + foreach ($params as $key => $value) { |
|
70 | 70 | if (property_exists($vehicle, $key)) { |
71 | 71 | $vehicle->{$key} = $value; |
72 | 72 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return $response; |
91 | 91 | } |
92 | 92 | |
93 | - public function getRandomVehicleId($page,$perPage) |
|
93 | + public function getRandomVehicleId($page, $perPage) |
|
94 | 94 | { |
95 | 95 | $query['page'] = isset($page) ? $page : 1; |
96 | 96 | $query['perPage'] = isset($perPage) ? $perPage : 10; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if (!isset($vehicles['data'])) return null; |
103 | 103 | if (sizeof($vehicles['data'])<1) return null; |
104 | 104 | |
105 | - $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
|
105 | + $randomIndex = rand(0, sizeof($vehicles['data']) - 1); |
|
106 | 106 | |
107 | 107 | return $vehicles['data'][$randomIndex]['vehicle_id']; |
108 | 108 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | public function getVehicleByID($vehicleID) |
111 | 111 | { |
112 | 112 | $response = Route4Me::makeRequst(array( |
113 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
113 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
114 | 114 | 'method' => 'GET' |
115 | 115 | )); |
116 | 116 | |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | |
124 | 124 | $body = array(); |
125 | 125 | |
126 | - $vehicle= new Vehicle(); |
|
126 | + $vehicle = new Vehicle(); |
|
127 | 127 | |
128 | - foreach($params as $key => $value) { |
|
128 | + foreach ($params as $key => $value) { |
|
129 | 129 | if ($key=="vehicle_id") continue; |
130 | 130 | if (property_exists($vehicle, $key)) { |
131 | 131 | if (isset($params->{$key})) { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | $response = Route4Me::makeRequst(array( |
138 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
138 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
139 | 139 | 'method' => 'PUT', |
140 | 140 | 'body' => $body, |
141 | 141 | 'HTTPHEADER' => 'Content-Type: application/json' |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | { |
149 | 149 | $body = array(); |
150 | 150 | |
151 | - $vehicle= new Vehicle(); |
|
151 | + $vehicle = new Vehicle(); |
|
152 | 152 | |
153 | - foreach($params as $key => $value) { |
|
153 | + foreach ($params as $key => $value) { |
|
154 | 154 | if ($key=="vehicle_id") continue; |
155 | 155 | if (property_exists($vehicle, $key)) { |
156 | 156 | if (isset($params->{$key})) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
175 | 175 | |
176 | 176 | $response = Route4Me::makeRequst(array( |
177 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
177 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
178 | 178 | 'method' => 'DELETE', |
179 | 179 | 'HTTPHEADER' => 'Content-Type: application/json' |
180 | 180 | )); |