@@ -42,7 +42,7 @@ |
||
| 42 | 42 | $param->addAddress($address); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if (isset($params['depots'] )) { |
|
| 45 | + if (isset($params['depots'])) { |
|
| 46 | 46 | foreach ($params['depots'] as $depot) { |
| 47 | 47 | if (!($depot instanceof Address)) { |
| 48 | 48 | $depot = Address::fromArray($depot); |
@@ -11,8 +11,8 @@ |
||
| 11 | 11 | |
| 12 | 12 | public function toArray() |
| 13 | 13 | { |
| 14 | - $params = array_filter(get_object_vars($this), function ($item) { |
|
| 15 | - return (null !== $item) && !(is_array($item) && !count($item)); |
|
| 14 | + $params = array_filter(get_object_vars($this), function($item) { |
|
| 15 | + return (null!==$item) && !(is_array($item) && !count($item)); |
|
| 16 | 16 | }); |
| 17 | 17 | |
| 18 | 18 | return $params; |
@@ -294,13 +294,13 @@ discard block |
||
| 294 | 294 | * Route notes |
| 295 | 295 | * @var AddressNote[] |
| 296 | 296 | */ |
| 297 | - public $notes=[]; |
|
| 297 | + public $notes = []; |
|
| 298 | 298 | |
| 299 | 299 | /** |
| 300 | 300 | * A vehicle assigned to the route. |
| 301 | 301 | * @var Vehicles\VehicleResponseV4 |
| 302 | 302 | */ |
| 303 | - public $vehicle=[]; |
|
| 303 | + public $vehicle = []; |
|
| 304 | 304 | |
| 305 | 305 | /** |
| 306 | 306 | * Member config key-value pairs. |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | */ |
| 414 | 414 | public static function getRoutes($params = null) |
| 415 | 415 | { |
| 416 | - $allQueryFields = ['route_id', 'original', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset','start_date','end_date']; |
|
| 416 | + $allQueryFields = ['route_id', 'original', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset', 'start_date', 'end_date']; |
|
| 417 | 417 | |
| 418 | 418 | $result = Route4Me::makeRequst([ |
| 419 | 419 | 'url' => Endpoint::ROUTE_V4, |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | */ |
| 529 | 529 | public function mergeRoutes($params) |
| 530 | 530 | { |
| 531 | - $allBodyFields = ['route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng']; |
|
| 531 | + $allBodyFields = ['route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng']; |
|
| 532 | 532 | |
| 533 | 533 | $result = Route4Me::makeRequst([ |
| 534 | 534 | 'url' => Endpoint::ROUTES_MERGE, |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | $route = new self(); |
| 583 | 583 | $routes = $route->getRoutes($params); |
| 584 | 584 | |
| 585 | - if (is_null($routes) || sizeof($routes) < 1) { |
|
| 585 | + if (is_null($routes) || sizeof($routes)<1) { |
|
| 586 | 586 | echo '<br> There are no routes in the account. Please, create the routes first. <br>'; |
| 587 | 587 | |
| 588 | 588 | return null; |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | */ |
| 608 | 608 | public function updateRoute($params) |
| 609 | 609 | { |
| 610 | - $allQueryFields = ['route_id', 'reoptimize','route_destination_id']; |
|
| 610 | + $allQueryFields = ['route_id', 'reoptimize', 'route_destination_id']; |
|
| 611 | 611 | $allBodyFields = ['addresses', 'parameters', 'unlink_from_master_optimization']; |
| 612 | 612 | |
| 613 | 613 | $result = Route4Me::makeRequst([ |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | public function updateAddress($address = null) |
| 643 | 643 | { |
| 644 | - $body = sizeof($this->addresses) < 1 ? get_object_vars($this->parameters) |
|
| 644 | + $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
| 645 | 645 | : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
| 646 | 646 | |
| 647 | 647 | $result = Route4Me::makeRequst([ |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | switch ($key) { |
| 236 | 236 | case 'cached_lat': |
| 237 | 237 | case 'curbside_lat': |
| 238 | - if ($coord[$key] > 90 || $coord[$key] < -90) { |
|
| 238 | + if ($coord[$key]>90 || $coord[$key]<-90) { |
|
| 239 | 239 | return false; |
| 240 | 240 | } |
| 241 | 241 | break; |
| 242 | 242 | case 'cached_lng': |
| 243 | 243 | case 'curbside_lng': |
| 244 | - if ($coord[$key] > 180 || $coord[$key] < -180) { |
|
| 244 | + if ($coord[$key]>180 || $coord[$key]<-180) { |
|
| 245 | 245 | return false; |
| 246 | 246 | } |
| 247 | 247 | break; |
@@ -274,14 +274,14 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | $iRow = 1; |
| 276 | 276 | |
| 277 | - while (false !== ($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))) { |
|
| 278 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && [null] !== $rows) { |
|
| 277 | + while (false!==($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))) { |
|
| 278 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && [null]!==$rows) { |
|
| 279 | 279 | $cached_lat = 0.000; |
| 280 | 280 | $cached_lng = 0.000; |
| 281 | 281 | |
| 282 | 282 | foreach (['cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng'] as $coord) { |
| 283 | 283 | if (!$this->validateCoordinate([$coord => $rows[$ordersFieldsMapping[$coord]]])) { |
| 284 | - array_push($results['fail'], "$iRow --> Wrong " + $coord); |
|
| 284 | + array_push($results['fail'], "$iRow --> Wrong " +$coord); |
|
| 285 | 285 | ++$iRow; |
| 286 | 286 | continue; |
| 287 | 287 | } else { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | public static function get($params) |
| 157 | 157 | { |
| 158 | 158 | $allQueryFields = ['state', 'limit', 'format', 'offset', |
| 159 | - 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
| 159 | + 'optimization_problem_id', 'wait_for_final_state', 'start_date', 'end_date', ]; |
|
| 160 | 160 | |
| 161 | 161 | $result = Route4Me::makeRequst([ |
| 162 | 162 | 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
| 244 | 244 | |
| 245 | 245 | if (!isset($rOptimization->optimization_problem_id)) { |
| 246 | - if (sizeof($optimizations) > 9) { |
|
| 246 | + if (sizeof($optimizations)>9) { |
|
| 247 | 247 | $this->getRandomOptimizationId($offset, $limit); |
| 248 | 248 | } else { |
| 249 | 249 | return null; |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | public function getAddresses($opt_id) |
| 257 | 257 | { |
| 258 | - if (null == $opt_id) { |
|
| 258 | + if (null==$opt_id) { |
|
| 259 | 259 | return null; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $params = ['optimization_problem_id' => $opt_id]; |
| 263 | 263 | |
| 264 | - $optimization = (array) $this->get($params); |
|
| 264 | + $optimization = (array)$this->get($params); |
|
| 265 | 265 | |
| 266 | 266 | $addresses = $optimization['addresses']; |
| 267 | 267 | |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | public function getRandomAddressFromOptimization($opt_id) |
| 272 | 272 | { |
| 273 | - $addresses = (array) $this->getAddresses($opt_id); |
|
| 273 | + $addresses = (array)$this->getAddresses($opt_id); |
|
| 274 | 274 | |
| 275 | - if (null == $addresses) { |
|
| 275 | + if (null==$addresses) { |
|
| 276 | 276 | echo 'There are no addresses in this optimization!.. Try again.'; |
| 277 | 277 | |
| 278 | 278 | return null; |
@@ -95,13 +95,13 @@ |
||
| 95 | 95 | * Telemetics connection vendor |
| 96 | 96 | * @var string |
| 97 | 97 | */ |
| 98 | - public $vendor ; |
|
| 98 | + public $vendor; |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Telemetics connection type ID |
| 102 | 102 | * @var integer |
| 103 | 103 | */ |
| 104 | - public $vendor_id ; |
|
| 104 | + public $vendor_id; |
|
| 105 | 105 | |
| 106 | 106 | public static function fromArray(array $params) |
| 107 | 107 | { |
@@ -123,11 +123,11 @@ |
||
| 123 | 123 | $allVendors = self::GetTelematicsVendors(null); |
| 124 | 124 | $vendorsNumber = sizeof($allVendors['vendors']); |
| 125 | 125 | |
| 126 | - if ($vendorsNumber < $limit) { |
|
| 127 | - if ($vendorsNumber > $offset) { |
|
| 126 | + if ($vendorsNumber<$limit) { |
|
| 127 | + if ($vendorsNumber>$offset) { |
|
| 128 | 128 | $limit = $vendorsNumber; |
| 129 | 129 | } else { |
| 130 | - if ($vendorsNumber == $offset) { |
|
| 130 | + if ($vendorsNumber==$offset) { |
|
| 131 | 131 | return $allVendors['vendors'][$offset]->{'vendor_id'}; |
| 132 | 132 | } else { |
| 133 | 133 | echo 'The vendors numbers are less than offset'; |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | |
| 240 | 240 | public function createVehicle($params) |
| 241 | 241 | { |
| 242 | - $excludeFields = ['vehicle_id','is_deleted','created_time','timestamp_added','timestamp_removed']; |
|
| 242 | + $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
| 243 | 243 | $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
| 244 | 244 | |
| 245 | 245 | //Route4Me::setBaseUrl(Endpoint::BASE_URL); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $vehicles = $this->getVehicles($params); |
| 112 | 112 | |
| 113 | - if (is_null($vehicles) || !isset($vehicles['data']) || sizeof($vehicles['data']) < 1) { |
|
| 113 | + if (is_null($vehicles) || !isset($vehicles['data']) || sizeof($vehicles['data'])<1) { |
|
| 114 | 114 | return null; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | public function getVehicleByID($vehicleID) |
| 123 | 123 | { |
| 124 | 124 | $response = Route4Me::makeRequst([ |
| 125 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
| 125 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
| 126 | 126 | 'method' => 'GET', |
| 127 | 127 | ]); |
| 128 | 128 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $allBodyFields = Route4Me::getObjectProperties(new self(), ['vehicle_id']); |
| 137 | 137 | |
| 138 | 138 | $response = Route4Me::makeRequst([ |
| 139 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
| 139 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
| 140 | 140 | 'method' => 'PUT', |
| 141 | 141 | 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
| 142 | 142 | 'HTTPHEADER' => 'Content-Type: application/json', |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
| 168 | 168 | |
| 169 | 169 | $response = Route4Me::makeRequst([ |
| 170 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
| 170 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
| 171 | 171 | 'method' => 'DELETE', |
| 172 | 172 | 'HTTPHEADER' => 'Content-Type: application/json', |
| 173 | 173 | ]); |