GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 210e2d...dface1 )
by Oleg
05:06
created
src/Route4Me/Route.php 1 patch
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 class Route extends Common
13 13
 {
14
-    static public $apiUrl = '/api.v4/route.php';
14
+	static public $apiUrl = '/api.v4/route.php';
15 15
 	static public $apiUrlAddress = '/api.v4/address.php';
16 16
 	static public $apiUrlDuplicate='/actions/duplicate_route.php';
17 17
 	static public $apiUrlDelete='/actions/delete_routes.php';
@@ -22,121 +22,121 @@  discard block
 block discarded – undo
22 22
 	static public $apiUrlAsset='/api.v4/status.php';
23 23
 	static public $apiUrlDeviceLocation='/api/track/get_device_location.php';
24 24
 	//static public $apiUrlMove='/actions/route/move_route_destination.php';
25
-    public $route_id;
25
+	public $route_id;
26 26
 	public $route_destination_id;
27
-    public $optimization_problem_id;
28
-    public $vehicle_alias;
29
-    public $driver_alias;
30
-    public $trip_distance;
31
-    public $mpg;
32
-    public $gas_price;
33
-    public $route_duration_sec;
34
-    public $parameters;
35
-    public $addresses = array();
36
-    public $links = array();
37
-    public $directions = array();
38
-    public $path = array();
39
-    public $tracking_history = array();
27
+	public $optimization_problem_id;
28
+	public $vehicle_alias;
29
+	public $driver_alias;
30
+	public $trip_distance;
31
+	public $mpg;
32
+	public $gas_price;
33
+	public $route_duration_sec;
34
+	public $parameters;
35
+	public $addresses = array();
36
+	public $links = array();
37
+	public $directions = array();
38
+	public $path = array();
39
+	public $tracking_history = array();
40 40
 	public $recipient_email;
41 41
 	public $httpheaders;
42 42
 	
43 43
 	public $dev_lat;
44 44
 	public $dev_lng;
45 45
 
46
-    public static function fromArray(array $params) 
47
-    {
48
-        $route = new Route();
49
-        $route->route_id = Common::getValue($params, 'route_id');
50
-        $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
51
-        $route->vehicle_alias = Common::getValue($params, 'vehicle_alias');
52
-        $route->driver_alias = Common::getValue($params, 'driver_alias');
53
-        $route->trip_distance = Common::getValue($params, 'trip_distance');
54
-        $route->mpg = Common::getValue($params, 'mpg');
55
-        $route->gas_price = Common::getValue($params, 'gas_price');
56
-        $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec');
57
-
58
-        // Make RouteParameters
59
-        if (isset($params['parameters'])) {
60
-            $route->parameters = RouteParameters::fromArray($params['parameters']);
61
-        }
62
-
63
-        if (isset($params['addresses'])) {
64
-            $addresses = array();
65
-            foreach ($params['addresses'] as $address) {
66
-                $addresses[] = Address::fromArray($address);
67
-            }
68
-
69
-            $route->addresses = $addresses;
70
-        }
71
-
72
-        $route->links = Common::getValue($params, 'links', array());
73
-        $route->directions = Common::getValue($params, 'directions', array());
74
-        $route->path = Common::getValue($params, 'path', array());
75
-        $route->tracking_history = Common::getValue($params, 'tracking_history', array());
76
-
77
-        return $route;
78
-    }
79
-
80
-    public static function getRoutes($routeId=null, $params=null)
81
-    {
82
-        $query = array(
83
-            'api_key' => Route4Me::getApiKey()
84
-        );
85
-
86
-        if ($routeId) {
87
-            $query['route_id'] = implode(',', (array) $routeId);
88
-        }
89
-
90
-        if ($params) {
91
-            if (isset($params['directions'])) {
92
-                $query['directions'] = $params['directions'];
93
-            }
94
-
95
-            if (isset($params['route_path_output'])) {
96
-                $query['route_path_output'] = $params['route_path_output'];
97
-            }
98
-
99
-            if (isset($params['device_tracking_history'])) {
100
-                $query['device_tracking_history'] = $params['device_tracking_history'];
101
-            }
46
+	public static function fromArray(array $params) 
47
+	{
48
+		$route = new Route();
49
+		$route->route_id = Common::getValue($params, 'route_id');
50
+		$route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
51
+		$route->vehicle_alias = Common::getValue($params, 'vehicle_alias');
52
+		$route->driver_alias = Common::getValue($params, 'driver_alias');
53
+		$route->trip_distance = Common::getValue($params, 'trip_distance');
54
+		$route->mpg = Common::getValue($params, 'mpg');
55
+		$route->gas_price = Common::getValue($params, 'gas_price');
56
+		$route->route_duration_sec = Common::getvalue($params, 'route_duration_sec');
57
+
58
+		// Make RouteParameters
59
+		if (isset($params['parameters'])) {
60
+			$route->parameters = RouteParameters::fromArray($params['parameters']);
61
+		}
62
+
63
+		if (isset($params['addresses'])) {
64
+			$addresses = array();
65
+			foreach ($params['addresses'] as $address) {
66
+				$addresses[] = Address::fromArray($address);
67
+			}
68
+
69
+			$route->addresses = $addresses;
70
+		}
71
+
72
+		$route->links = Common::getValue($params, 'links', array());
73
+		$route->directions = Common::getValue($params, 'directions', array());
74
+		$route->path = Common::getValue($params, 'path', array());
75
+		$route->tracking_history = Common::getValue($params, 'tracking_history', array());
76
+
77
+		return $route;
78
+	}
79
+
80
+	public static function getRoutes($routeId=null, $params=null)
81
+	{
82
+		$query = array(
83
+			'api_key' => Route4Me::getApiKey()
84
+		);
85
+
86
+		if ($routeId) {
87
+			$query['route_id'] = implode(',', (array) $routeId);
88
+		}
89
+
90
+		if ($params) {
91
+			if (isset($params['directions'])) {
92
+				$query['directions'] = $params['directions'];
93
+			}
94
+
95
+			if (isset($params['route_path_output'])) {
96
+				$query['route_path_output'] = $params['route_path_output'];
97
+			}
98
+
99
+			if (isset($params['device_tracking_history'])) {
100
+				$query['device_tracking_history'] = $params['device_tracking_history'];
101
+			}
102 102
 			
103 103
 			if (isset($params['query'])) {
104
-                $query['query'] = $params['query'];
105
-            }
106
-
107
-            $query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
108
-            $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
109
-        }
104
+				$query['query'] = $params['query'];
105
+			}
110 106
 
111
-        $json = Route4Me::makeRequst(array(
112
-            'url'    => self::$apiUrl,
113
-            'method' => 'GET',
114
-            'query'  => $query
115
-        ));
107
+			$query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
108
+			$query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
109
+		}
116 110
 
117
-        if ($routeId) {
118
-            return Route::fromArray($json); die("");
119
-        } else {
120
-            $routes = array();
121
-            foreach($json as $route) {
122
-                $routes[] = Route::fromArray($route);
123
-            }
124
-            return $routes;
125
-        }
126
-    }
111
+		$json = Route4Me::makeRequst(array(
112
+			'url'    => self::$apiUrl,
113
+			'method' => 'GET',
114
+			'query'  => $query
115
+		));
116
+
117
+		if ($routeId) {
118
+			return Route::fromArray($json); die("");
119
+		} else {
120
+			$routes = array();
121
+			foreach($json as $route) {
122
+				$routes[] = Route::fromArray($route);
123
+			}
124
+			return $routes;
125
+		}
126
+	}
127 127
 
128 128
 	public function getRoutePoints($routeId, $params)
129 129
 	{
130 130
 		$result = Route4Me::makeRequst(array(
131
-            'url'    => self::$apiUrl,
132
-            'method' => 'GET',
133
-            'query'  => array(
134
-            	'api_key' => Route4Me::getApiKey(),
135
-                'route_id' => $routeId,
136
-                'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null,
137
-                'directions' => isset($params['directions']) ? $params['directions'] : null,
138
-            )
139
-        ));
131
+			'url'    => self::$apiUrl,
132
+			'method' => 'GET',
133
+			'query'  => array(
134
+				'api_key' => Route4Me::getApiKey(),
135
+				'route_id' => $routeId,
136
+				'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null,
137
+				'directions' => isset($params['directions']) ? $params['directions'] : null,
138
+			)
139
+		));
140 140
 
141 141
 		return $result;
142 142
 	}
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	public function duplicateRoute($route_id)
145 145
 	{
146 146
 		$result = Route4Me::makeRequst(array(
147
-            'url'    => self::$apiUrlDuplicate,
148
-            'method' => 'GET',
149
-            'query'  => array(
150
-            	'api_key' => Route4Me::getApiKey(),
151
-                'route_id' => $route_id,
152
-                'to' => 'none',
153
-            )
154
-        ));
147
+			'url'    => self::$apiUrlDuplicate,
148
+			'method' => 'GET',
149
+			'query'  => array(
150
+				'api_key' => Route4Me::getApiKey(),
151
+				'route_id' => $route_id,
152
+				'to' => 'none',
153
+			)
154
+		));
155 155
 		
156 156
 		return $result;
157 157
 	}
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	public function resequenceRoute($params)
160 160
 	{
161 161
 		$result = Route4Me::makeRequst(array(
162
-            'url'    => self::$apiUrl,
163
-            'method' => 'PUT',
164
-            'query'  => array(
165
-            	'api_key' => Route4Me::getApiKey(),
166
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
167
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
168
-            ),
169
-            'body'  => array(
162
+			'url'    => self::$apiUrl,
163
+			'method' => 'PUT',
164
+			'query'  => array(
165
+				'api_key' => Route4Me::getApiKey(),
166
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
167
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
168
+			),
169
+			'body'  => array(
170 170
 				'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
171 171
 			)
172
-        ));
172
+		));
173 173
 		
174 174
 		return $result;
175 175
 	}
@@ -177,15 +177,15 @@  discard block
 block discarded – undo
177 177
 	public function resequenceAllAddresses($params)
178 178
 	{
179 179
 		$result = Route4Me::makeRequst(array(
180
-            'url'    => self::$apiUrlReseq,
181
-            'method' => 'GET',
182
-            'query'  => array(
183
-            	'api_key' => Route4Me::getApiKey(),
184
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
185
-                'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null,
186
-                'optimize' => isset($params['optimize']) ? $params['optimize'] : null,
187
-            )
188
-        ));
180
+			'url'    => self::$apiUrlReseq,
181
+			'method' => 'GET',
182
+			'query'  => array(
183
+				'api_key' => Route4Me::getApiKey(),
184
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
185
+				'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null,
186
+				'optimize' => isset($params['optimize']) ? $params['optimize'] : null,
187
+			)
188
+		));
189 189
 		
190 190
 		return $result;
191 191
 		
@@ -194,16 +194,16 @@  discard block
 block discarded – undo
194 194
 	public function mergeRoutes($params)
195 195
 	{
196 196
 		$result = Route4Me::makeRequst(array(
197
-            'url'    => self::$apiUrlMerge,
198
-            'method' => 'POST',
199
-            'query'  => array(
200
-            	'api_key' => Route4Me::getApiKey(),
201
-            ),
202
-            'body'  => array(
197
+			'url'    => self::$apiUrlMerge,
198
+			'method' => 'POST',
199
+			'query'  => array(
200
+				'api_key' => Route4Me::getApiKey(),
201
+			),
202
+			'body'  => array(
203 203
 				'route_ids' => isset($params['route_ids']) ? $params['route_ids'] : null,
204 204
 			),
205 205
 			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
206
-        ));
206
+		));
207 207
 		
208 208
 		return $result;
209 209
 	}
@@ -211,17 +211,17 @@  discard block
 block discarded – undo
211 211
 	public function shareRoute($params)
212 212
 	{
213 213
 		$result = Route4Me::makeRequst(array(
214
-            'url'    => self::$apiUrlShare,
215
-            'method' => 'POST',
216
-            'query'  => array(
217
-            	'api_key' => Route4Me::getApiKey(),
218
-            	'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
219
-            ),
220
-            'body'  => array(
214
+			'url'    => self::$apiUrlShare,
215
+			'method' => 'POST',
216
+			'query'  => array(
217
+				'api_key' => Route4Me::getApiKey(),
218
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
219
+			),
220
+			'body'  => array(
221 221
 				'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null,
222 222
 			),
223 223
 			'Content-Type' => 'multipart/form-data'
224
-        ));
224
+		));
225 225
 		
226 226
 		return $result;
227 227
 	}
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 	public function getRandomRouteId($offset,$limit)
231 231
 	{
232 232
 		$query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
233
-        $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
233
+		$query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
234 234
 			
235 235
 		$json = Route4Me::makeRequst(array(
236
-            'url'    => self::$apiUrl,
237
-            'method' => 'GET',
238
-            'query'  => $query
239
-        ));
236
+			'url'    => self::$apiUrl,
237
+			'method' => 'GET',
238
+			'query'  => $query
239
+		));
240 240
 		
241 241
 		$routes = array();
242
-            foreach($json as $route) {
243
-                $routes[] = Route::fromArray($route);
244
-            }
242
+			foreach($json as $route) {
243
+				$routes[] = Route::fromArray($route);
244
+			}
245 245
 			
246 246
 			$num=rand(0,sizeof($routes)-1);
247 247
 			$rRoute=(array)$routes[$num];
@@ -253,71 +253,71 @@  discard block
 block discarded – undo
253 253
 			else return null;
254 254
 	}
255 255
 
256
-    public function update()
257
-    {
258
-        $route = Route4Me::makeRequst(array(
259
-            'url'    => self::$apiUrl,
260
-            'method' => 'PUT',
261
-            'query'  => array(
262
-                'route_id' => isset($this->route_id) ? $this->route_id : null,
263
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
264
-            ),
265
-            'body' => array (
266
-            	'parameters' => $this->parameters,
267
-            	),
268
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
269
-        ));
256
+	public function update()
257
+	{
258
+		$route = Route4Me::makeRequst(array(
259
+			'url'    => self::$apiUrl,
260
+			'method' => 'PUT',
261
+			'query'  => array(
262
+				'route_id' => isset($this->route_id) ? $this->route_id : null,
263
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
264
+			),
265
+			'body' => array (
266
+				'parameters' => $this->parameters,
267
+				),
268
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
269
+		));
270 270
 
271
-        return Route::fromArray($route);
272
-    }
271
+		return Route::fromArray($route);
272
+	}
273 273
 	
274 274
 	public function updateAddress()
275
-    {
276
-        $result = Route4Me::makeRequst(array(
277
-            'url'    => self::$apiUrlAddress,
278
-            'method' => 'PUT',
279
-            'query'  => array(
280
-                'route_id' => isset($this->route_id) ? $this->route_id : null,
281
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
282
-            ),
283
-            'body' => get_object_vars($this->parameters),
284
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
285
-        ));
275
+	{
276
+		$result = Route4Me::makeRequst(array(
277
+			'url'    => self::$apiUrlAddress,
278
+			'method' => 'PUT',
279
+			'query'  => array(
280
+				'route_id' => isset($this->route_id) ? $this->route_id : null,
281
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
282
+			),
283
+			'body' => get_object_vars($this->parameters),
284
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
285
+		));
286 286
 
287
-        return $result;
288
-    }
287
+		return $result;
288
+	}
289 289
 
290
-    public function addAddresses(array $params)
291
-    {
292
-        $route = Route4Me::makeRequst(array(
293
-            'url'    => self::$apiUrl,
294
-            'method' => 'PUT',
295
-            'query'  => array(
296
-            	'api_key' => Route4Me::getApiKey(),
297
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
298
-                'addresses' => isset($params['addresses']) ? $params['addresses'] : null
299
-            )
300
-        ));
290
+	public function addAddresses(array $params)
291
+	{
292
+		$route = Route4Me::makeRequst(array(
293
+			'url'    => self::$apiUrl,
294
+			'method' => 'PUT',
295
+			'query'  => array(
296
+				'api_key' => Route4Me::getApiKey(),
297
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
298
+				'addresses' => isset($params['addresses']) ? $params['addresses'] : null
299
+			)
300
+		));
301 301
 
302
-        return Route::fromArray($route);
303
-    }
302
+		return Route::fromArray($route);
303
+	}
304 304
 	
305 305
 	public function insertAddressOptimalPosition(array $params)
306 306
 	{
307 307
 		$route = Route4Me::makeRequst(array(
308
-            'url'    => self::$apiUrl,
309
-            'method' => 'PUT',
310
-            'query'  => array(
311
-            	'api_key' => Route4Me::getApiKey(),
312
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
313
-            ),
314
-            'body'  => array(
308
+			'url'    => self::$apiUrl,
309
+			'method' => 'PUT',
310
+			'query'  => array(
311
+				'api_key' => Route4Me::getApiKey(),
312
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
313
+			),
314
+			'body'  => array(
315 315
 				'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
316 316
 				'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null,
317 317
 			)
318
-        ));
318
+		));
319 319
 
320
-        return Route::fromArray($route);
320
+		return Route::fromArray($route);
321 321
 	}
322 322
 	
323 323
 	public function addNoteFile($params)
@@ -326,18 +326,18 @@  discard block
 block discarded – undo
326 326
 		$rpath = realpath($fname);
327 327
 		//echo $rpath;die("");
328 328
 		$result= Route4Me::makeRequst(array(
329
-            'url'    => self::$apiUrlNoteFile,
330
-            'method' => 'POST',
331
-            'query'  => array(
332
-            	'api_key' => Route4Me::getApiKey(),
333
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
334
-                'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
335
-                'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null,
336
-                'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null,
337
-                'device_type' => isset($params['device_type']) ? $params['device_type'] : null,
338
-                'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null,
339
-            ),
340
-            'body'  => array(
329
+			'url'    => self::$apiUrlNoteFile,
330
+			'method' => 'POST',
331
+			'query'  => array(
332
+				'api_key' => Route4Me::getApiKey(),
333
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
334
+				'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
335
+				'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null,
336
+				'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null,
337
+				'device_type' => isset($params['device_type']) ? $params['device_type'] : null,
338
+				'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null,
339
+			),
340
+			'body'  => array(
341 341
 				'strUpdateType' => isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
342 342
 				'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null,
343 343
 				'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
@@ -347,18 +347,18 @@  discard block
 block discarded – undo
347 347
 			'HTTPHEADER' => array(
348 348
 				'Content-Type: application/x-www-form-urlencoded'
349 349
 			)
350
-        ));
350
+		));
351 351
 
352
-        return $result;
352
+		return $result;
353 353
 	}
354 354
 
355
-    public function delete($route_id)
356
-    {
357
-        $result = Route4Me::makeRequst(array(
358
-            'url'    => self::$apiUrl,
359
-            'method' => 'DELETE',
360
-            'query'  => array( 'route_id' => $route_id )
361
-        ));
355
+	public function delete($route_id)
356
+	{
357
+		$result = Route4Me::makeRequst(array(
358
+			'url'    => self::$apiUrl,
359
+			'method' => 'DELETE',
360
+			'query'  => array( 'route_id' => $route_id )
361
+		));
362 362
 		
363 363
 		// The code below doesn't work, altough this method is described as workable in REST API 
364 364
 		/*
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
             )
372 372
         ));
373 373
 		*/
374
-        return $result;
375
-    }
374
+		return $result;
375
+	}
376 376
 	
377 377
 	public function GetAddressesFromRoute($route_id)
378 378
 	{
@@ -396,63 +396,63 @@  discard block
 block discarded – undo
396 396
 		} else { return null;}
397 397
 	}
398 398
 
399
-    public function getRouteId()
400
-    {
401
-        return $this->route_id;
402
-    }
399
+	public function getRouteId()
400
+	{
401
+		return $this->route_id;
402
+	}
403 403
 
404
-    public function getOptimizationId()
405
-    {
406
-        return $this->optimization_problem_id;
407
-    }
404
+	public function getOptimizationId()
405
+	{
406
+		return $this->optimization_problem_id;
407
+	}
408 408
 	
409 409
 	public function GetLastLocation(array $params)
410 410
 	{
411 411
 		$route = Route4Me::makeRequst(array(
412
-            'url'    => self::$apiUrl,
413
-            'method' => 'GET',
414
-            'query'  => array(
415
-            	'api_key' => Route4Me::getApiKey(),
416
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
417
-                'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null
418
-            )
419
-        ));
412
+			'url'    => self::$apiUrl,
413
+			'method' => 'GET',
414
+			'query'  => array(
415
+				'api_key' => Route4Me::getApiKey(),
416
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
417
+				'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null
418
+			)
419
+		));
420 420
 
421
-        return Route::fromArray($route);
421
+		return Route::fromArray($route);
422 422
 		
423 423
 	}
424 424
 	
425 425
 	public function GetTrackingHistoryFromTimeRange(array $params)
426 426
 	{
427 427
 		$route = Route4Me::makeRequst(array(
428
-            'url'    => self::$apiUrlDeviceLocation,
429
-            'method' => 'GET',
430
-            'query'  => array(
431
-            	'api_key' => Route4Me::getApiKey(),
432
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
433
-                'format' => isset($params['format']) ? $params['format'] : null,
434
-                'time_period' => isset($params['time_period']) ? $params['time_period'] : null,
435
-                'start_date' => isset($params['start_date']) ? $params['start_date'] : null,
436
-                'end_date' => isset($params['end_date']) ? $params['end_date'] : null
437
-                )
438
-        ));
439
-
440
-        return $route;
428
+			'url'    => self::$apiUrlDeviceLocation,
429
+			'method' => 'GET',
430
+			'query'  => array(
431
+				'api_key' => Route4Me::getApiKey(),
432
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
433
+				'format' => isset($params['format']) ? $params['format'] : null,
434
+				'time_period' => isset($params['time_period']) ? $params['time_period'] : null,
435
+				'start_date' => isset($params['start_date']) ? $params['start_date'] : null,
436
+				'end_date' => isset($params['end_date']) ? $params['end_date'] : null
437
+				)
438
+		));
439
+
440
+		return $route;
441 441
 		
442 442
 	}
443 443
 	
444 444
 	public function GetAssetTracking(array $params)
445 445
 	{
446 446
 		$route = Route4Me::makeRequst(array(
447
-            'url'    => self::$apiUrlAsset,
448
-            'method' => 'GET',
449
-            'query'  => array(
450
-            	'api_key' => Route4Me::getApiKey(),
451
-                'tracking' => isset($params['tracking']) ? $params['tracking'] : null
452
-                )
453
-        ));
454
-
455
-        return $route;
447
+			'url'    => self::$apiUrlAsset,
448
+			'method' => 'GET',
449
+			'query'  => array(
450
+				'api_key' => Route4Me::getApiKey(),
451
+				'tracking' => isset($params['tracking']) ? $params['tracking'] : null
452
+				)
453
+		));
454
+
455
+		return $route;
456 456
 		
457 457
 	}
458 458
 }
Please login to merge, or discard this patch.
src/Route4Me/curl_http_client.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		//and finally send curl request
111 111
 		$result = curl_exec_redir($this->ch);
112 112
 		if(curl_errno($this->ch))
113
-        {
113
+		{
114 114
 			if($this->debug)
115 115
 			{
116 116
 				echo "Error Occured in Curl\n";
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			return false;
121 121
 		}
122 122
 		else
123
-        {
123
+		{
124 124
 			return $result;
125 125
 		}
126 126
 	}
@@ -372,53 +372,53 @@  discard block
 block discarded – undo
372 372
  */
373 373
 function curl_exec_redir($ch)
374 374
 {
375
-    static $curl_loops = 0;
376
-    static $curl_max_loops = 20;
377
-    if ($curl_loops++ >= $curl_max_loops)
378
-    {
379
-        $curl_loops = 0;
380
-        return FALSE;
381
-    }
382
-    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
383
-    curl_setopt($ch, CURLOPT_HEADER, true);
384
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
385
-    curl_setopt($ch, CURLOPT_VERBOSE, false);
386
-    $data = curl_exec($ch);
387
-    $data = str_replace("\r", "\n", str_replace("\r\n", "\n", $data));
388
-    list($header, $data) = explode("\n\n", $data, 2);
389
-    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
375
+	static $curl_loops = 0;
376
+	static $curl_max_loops = 20;
377
+	if ($curl_loops++ >= $curl_max_loops)
378
+	{
379
+		$curl_loops = 0;
380
+		return FALSE;
381
+	}
382
+	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
383
+	curl_setopt($ch, CURLOPT_HEADER, true);
384
+	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
385
+	curl_setopt($ch, CURLOPT_VERBOSE, false);
386
+	$data = curl_exec($ch);
387
+	$data = str_replace("\r", "\n", str_replace("\r\n", "\n", $data));
388
+	list($header, $data) = explode("\n\n", $data, 2);
389
+	$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
390 390
     
391
-    //echo "*** Got HTTP code: $http_code ***\n";
392
-    //echo "**  Got headers: \n$header\n\n";
391
+	//echo "*** Got HTTP code: $http_code ***\n";
392
+	//echo "**  Got headers: \n$header\n\n";
393 393
     
394
-    if ( $http_code == 301 || $http_code == 302 )
395
-    {
396
-        // If we're redirected, we should revert to GET
394
+	if ( $http_code == 301 || $http_code == 302 )
395
+	{
396
+		// If we're redirected, we should revert to GET
397 397
 		curl_setopt($ch, CURLOPT_HTTPGET,true);
398 398
         
399
-        $matches = array();
400
-        preg_match('/Location:\s*(.*?)(\n|$)/i', $header, $matches);
401
-        $url = @parse_url(trim($matches[1]));
402
-        if (!$url)
403
-        {
404
-            //couldn't process the url to redirect to
405
-            $curl_loops = 0;
406
-            return $data;
407
-        }
408
-        $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
409
-        if (empty($url['scheme']))
410
-            $url['scheme'] = $last_url['scheme'];
411
-        if (empty($url['host']))
412
-            $url['host'] = $last_url['host'];
413
-        if (empty($url['path']))
414
-            $url['path'] = $last_url['path'];
415
-        $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:'');
416
-        //echo "Being redirected to $new_url\n";
417
-        curl_setopt($ch, CURLOPT_URL, $new_url);
418
-        return curl_exec_redir($ch);
419
-    } else {
420
-        $curl_loops=0;
421
-        return $data;
422
-    }
399
+		$matches = array();
400
+		preg_match('/Location:\s*(.*?)(\n|$)/i', $header, $matches);
401
+		$url = @parse_url(trim($matches[1]));
402
+		if (!$url)
403
+		{
404
+			//couldn't process the url to redirect to
405
+			$curl_loops = 0;
406
+			return $data;
407
+		}
408
+		$last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
409
+		if (empty($url['scheme']))
410
+			$url['scheme'] = $last_url['scheme'];
411
+		if (empty($url['host']))
412
+			$url['host'] = $last_url['host'];
413
+		if (empty($url['path']))
414
+			$url['path'] = $last_url['path'];
415
+		$new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:'');
416
+		//echo "Being redirected to $new_url\n";
417
+		curl_setopt($ch, CURLOPT_URL, $new_url);
418
+		return curl_exec_redir($ch);
419
+	} else {
420
+		$curl_loops=0;
421
+		return $data;
422
+	}
423 423
 }
424 424
 ?>
Please login to merge, or discard this patch.
src/Route4Me/Geocoding.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 		
24 24
 		public static function fromArray(array $params) {
25 25
 			$geocoding = new Geocoding();
26
-	        foreach($params as $key => $value) {
27
-	            if (property_exists($geocoding, $key)) {
28
-	                $geocoding->{$key} = $value;
29
-	            }
26
+			foreach($params as $key => $value) {
27
+				if (property_exists($geocoding, $key)) {
28
+					$geocoding->{$key} = $value;
29
+				}
30 30
 			}
31 31
 			return $geocoding;
32 32
 		}
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
 		{
36 36
 			//Route4Me::simplePrint($params);
37 37
 			$query = array(
38
-	                'format' => isset($params['format']) ? $params['format']: null,
39
-	                'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
40
-	            );
38
+					'format' => isset($params['format']) ? $params['format']: null,
39
+					'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
40
+				);
41 41
 			//var_dump($query);
42 42
 			$fgcoding = Route4Me::makeRequst(array(
43
-	            'url'    => self::$apiUrl,
44
-	            'method' => 'POST',
45
-	            'query'  => $query
46
-	        ));
43
+				'url'    => self::$apiUrl,
44
+				'method' => 'POST',
45
+				'query'  => $query
46
+			));
47 47
 			
48 48
 			return $fgcoding;
49 49
 		}
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 			$query = array();
65 65
 			
66 66
 			$response = Route4Me::makeUrlRequst($url_query, array(
67
-	            'method' => 'GET',
68
-	            'query'  => $query
69
-	        ));
67
+				'method' => 'GET',
68
+				'query'  => $query
69
+			));
70 70
 			
71 71
 			return $response;
72 72
 		}
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 			$query = array();
88 88
 			
89 89
 			$response = Route4Me::makeUrlRequst($url_query, array(
90
-	            'method' => 'GET',
91
-	            'query'  => $query
92
-	        ));
90
+				'method' => 'GET',
91
+				'query'  => $query
92
+			));
93 93
 			
94 94
 			return $response;
95 95
 		}
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 			$query = array();
114 114
 			
115 115
 			$response = Route4Me::makeUrlRequst($url_query, array(
116
-	            'method' => 'GET',
117
-	            'query'  => $query
118
-	        ));
116
+				'method' => 'GET',
117
+				'query'  => $query
118
+			));
119 119
 			
120 120
 			return $response;
121 121
 		}
Please login to merge, or discard this patch.
src/Route4Me/Common.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 block discarded – undo
4 4
 
5 5
 class Common
6 6
 {
7
-    static public function getValue($array, $item, $default = null)
8
-    {
9
-        return (isset($array[$item])) ? $array[$item] : $default;
10
-    }
7
+	static public function getValue($array, $item, $default = null)
8
+	{
9
+		return (isset($array[$item])) ? $array[$item] : $default;
10
+	}
11 11
 
12
-    public function toArray()
13
-    {
14
-        $params = array_filter(get_object_vars($this), function($item) {
15
-            return ($item !== null) && !(is_array($item) && !count($item));
16
-        });
12
+	public function toArray()
13
+	{
14
+		$params = array_filter(get_object_vars($this), function($item) {
15
+			return ($item !== null) && !(is_array($item) && !count($item));
16
+		});
17 17
 
18
-        return $params;
19
-    }
18
+		return $params;
19
+	}
20 20
 }
Please login to merge, or discard this patch.
src/Route4Me/AvoidanceZone.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -20,93 +20,93 @@
 block discarded – undo
20 20
 		
21 21
 		public static function fromArray(array $params) {
22 22
 			if (!isset($params['territory_name'])) {
23
-	            throw new BadParam('Territory name must be provided');
24
-	        }
23
+				throw new BadParam('Territory name must be provided');
24
+			}
25 25
 			
26 26
 			if (!isset($params['territory_color'])) {
27
-	            throw new BadParam('Territory color must be provided');
28
-	        }
27
+				throw new BadParam('Territory color must be provided');
28
+			}
29 29
 			
30 30
 			if (!isset($params['territory'])) {
31
-	            throw new BadParam('Territory must be provided');
32
-	        }
31
+				throw new BadParam('Territory must be provided');
32
+			}
33 33
 			
34 34
 			$avoidancezoneparameters = new AvoidanceZone();
35
-	        foreach($params as $key => $value) {
36
-	            if (property_exists($avoidancezoneparameters, $key)) {
37
-	                $avoidancezoneparameters->{$key} = $value;
38
-	            }
35
+			foreach($params as $key => $value) {
36
+				if (property_exists($avoidancezoneparameters, $key)) {
37
+					$avoidancezoneparameters->{$key} = $value;
38
+				}
39 39
 			}
40 40
 			
41 41
 			return $avoidancezoneparameters;
42 42
 		}
43 43
 		
44 44
 		public static function getAvoidanceZone($territory_id)
45
-	    {
46
-	        $avoidancezone = Route4Me::makeRequst(array(
47
-	            'url'    => self::$apiUrl,
48
-	            'method' => 'GET',
49
-	            'query'  => array(
50
-	                'territory_id'             => $territory_id
51
-	            )
52
-	        ));
45
+		{
46
+			$avoidancezone = Route4Me::makeRequst(array(
47
+				'url'    => self::$apiUrl,
48
+				'method' => 'GET',
49
+				'query'  => array(
50
+					'territory_id'             => $territory_id
51
+				)
52
+			));
53 53
 	
54
-	        return $avoidancezone;
55
-	    }
54
+			return $avoidancezone;
55
+		}
56 56
 		
57 57
 		public static function getAvoidanceZones($params)
58
-	    {
59
-	        $avoidancezones = Route4Me::makeRequst(array(
60
-	            'url'    => self::$apiUrl,
61
-	            'method' => 'GET',
62
-	            'query'  => array(
63
-	                'offset'  => isset($params->offset) ? $params->offset: null,
64
-	                'limit'   => isset($params->limit) ? $params->limit: null,
65
-	            )
66
-	        ));
58
+		{
59
+			$avoidancezones = Route4Me::makeRequst(array(
60
+				'url'    => self::$apiUrl,
61
+				'method' => 'GET',
62
+				'query'  => array(
63
+					'offset'  => isset($params->offset) ? $params->offset: null,
64
+					'limit'   => isset($params->limit) ? $params->limit: null,
65
+				)
66
+			));
67 67
 	
68
-	        return $avoidancezones;
69
-	    }
68
+			return $avoidancezones;
69
+		}
70 70
 
71 71
 		public static function addAvoidanceZone($params)
72
-	    {
73
-	    	$abcontacts = Route4Me::makeRequst(array(
74
-	            'url'    => self::$apiUrl,
75
-	            'method' => 'ADD',
76
-	            'query'  => array(
77
-	            	'territory_name' => 	isset($params->territory_name) ? $params->territory_name: null,
78
-	                'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
79
-	                'territory' => isset($params->territory) ? $params->territory : null,
80
-	            )
81
-	        ));
72
+		{
73
+			$abcontacts = Route4Me::makeRequst(array(
74
+				'url'    => self::$apiUrl,
75
+				'method' => 'ADD',
76
+				'query'  => array(
77
+					'territory_name' => 	isset($params->territory_name) ? $params->territory_name: null,
78
+					'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
79
+					'territory' => isset($params->territory) ? $params->territory : null,
80
+				)
81
+			));
82 82
 
83 83
 			return $abcontacts;
84 84
 		}
85 85
 		
86 86
 		public function deleteAvoidanceZone($territory_id)
87
-	    {
88
-	        $result = Route4Me::makeRequst(array(
89
-	            'url'    => self::$apiUrl,
90
-	            'method' => 'DELETEARRAY',
91
-	            'query'  => array(
92
-	                'territory_id'     => $territory_id
93
-	            )
94
-	        ));
87
+		{
88
+			$result = Route4Me::makeRequst(array(
89
+				'url'    => self::$apiUrl,
90
+				'method' => 'DELETEARRAY',
91
+				'query'  => array(
92
+					'territory_id'     => $territory_id
93
+				)
94
+			));
95 95
 	
96
-	        return $result;
97
-	    }
96
+			return $result;
97
+		}
98 98
 		
99 99
 		public function updateAvoidanceZone($params)
100
-	    {
101
-	        $avoidancezone = Route4Me::makeRequst(array(
102
-	            'url'    => self::$apiUrl,
103
-	            'method' => 'PUT',
104
-	            'query'   => (array)$params,
100
+		{
101
+			$avoidancezone = Route4Me::makeRequst(array(
102
+				'url'    => self::$apiUrl,
103
+				'method' => 'PUT',
104
+				'query'   => (array)$params,
105 105
 
106
-	        ));
106
+			));
107 107
 	
108
-	        return $avoidancezone;
109
-	    }
108
+			return $avoidancezone;
109
+		}
110 110
 	}
111 111
 	
112 112
 ?>
113 113
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/Address.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -9,55 +9,55 @@  discard block
 block discarded – undo
9 9
 
10 10
 class Address extends Common
11 11
 {
12
-    static public $apiUrl = '/api.v4/address.php';
12
+	static public $apiUrl = '/api.v4/address.php';
13 13
 	static public $apiUrlMove='/actions/route/move_route_destination.php';
14 14
 	static public $apiUrDeparted='/api/route/mark_address_departed.php';
15 15
 	static public $apiUrVisited='/actions/address/update_address_visited.php';
16 16
 
17
-    public $route_destination_id;
18
-    public $alias;
19
-    public $member_id;
20
-    public $address;
21
-    public $is_depot = false;
22
-    public $lat;
23
-    public $lng;
24
-    public $route_id;
25
-    public $original_route_id;
26
-    public $optimization_problem_id;
27
-    public $sequence_no;
28
-    public $geocoded;
29
-    public $preferred_geocoding;
30
-    public $failed_geocoding;
31
-    public $geocodings = array();
32
-    public $contact_id;
33
-    public $is_visited;
34
-    public $customer_po;
35
-    public $invoice_no;
36
-    public $reference_no;
37
-    public $order_no;
38
-    public $weight;
39
-    public $cost;
40
-    public $revenue;
41
-    public $cube;
42
-    public $pieces;
43
-    public $email;
44
-    public $phone;
45
-    public $destination_note_count;
46
-    public $drive_time_to_next_destination;
47
-    public $distance_to_next_destination;
48
-    public $generated_time_window_start;
49
-    public $generated_time_window_end;
50
-    public $time_window_start;
51
-    public $time_window_end;
52
-    public $time;
17
+	public $route_destination_id;
18
+	public $alias;
19
+	public $member_id;
20
+	public $address;
21
+	public $is_depot = false;
22
+	public $lat;
23
+	public $lng;
24
+	public $route_id;
25
+	public $original_route_id;
26
+	public $optimization_problem_id;
27
+	public $sequence_no;
28
+	public $geocoded;
29
+	public $preferred_geocoding;
30
+	public $failed_geocoding;
31
+	public $geocodings = array();
32
+	public $contact_id;
33
+	public $is_visited;
34
+	public $customer_po;
35
+	public $invoice_no;
36
+	public $reference_no;
37
+	public $order_no;
38
+	public $weight;
39
+	public $cost;
40
+	public $revenue;
41
+	public $cube;
42
+	public $pieces;
43
+	public $email;
44
+	public $phone;
45
+	public $destination_note_count;
46
+	public $drive_time_to_next_destination;
47
+	public $distance_to_next_destination;
48
+	public $generated_time_window_start;
49
+	public $generated_time_window_end;
50
+	public $time_window_start;
51
+	public $time_window_end;
52
+	public $time;
53 53
 	public $notes;
54
-    public $timestamp_last_visited;
55
-    public $custom_fields = array();
56
-    public $manifest = array();
54
+	public $timestamp_last_visited;
55
+	public $custom_fields = array();
56
+	public $manifest = array();
57 57
 
58
-    public static function fromArray(array $params)
59
-    {
60
-        /*if (!isset($params['address'])) {
58
+	public static function fromArray(array $params)
59
+	{
60
+		/*if (!isset($params['address'])) {
61 61
             throw new BadParam('address must be provided');
62 62
         }
63 63
 
@@ -69,124 +69,124 @@  discard block
 block discarded – undo
69 69
             throw new BadParam('lng must be provided');
70 70
         }*/
71 71
 
72
-        $address = new Address();
73
-        foreach($params as $key => $value) {
74
-            if (property_exists($address, $key)) {
75
-                $address->{$key} = $value;
76
-            }
77
-        }
72
+		$address = new Address();
73
+		foreach($params as $key => $value) {
74
+			if (property_exists($address, $key)) {
75
+				$address->{$key} = $value;
76
+			}
77
+		}
78
+
79
+		return $address;
80
+	}
81
+
82
+	public static function getAddress($routeId, $addressId)
83
+	{
84
+		$address = Route4Me::makeRequst(array(
85
+			'url'    => self::$apiUrl,
86
+			'method' => 'GET',
87
+			'query'  => array(
88
+				'route_id'             => $routeId,
89
+				'route_destination_id' => $addressId,
90
+			)
91
+		));
92
+
93
+		return Address::fromArray($address);
94
+	}
78 95
 
79
-        return $address;
80
-    }
81
-
82
-    public static function getAddress($routeId, $addressId)
83
-    {
84
-        $address = Route4Me::makeRequst(array(
85
-            'url'    => self::$apiUrl,
86
-            'method' => 'GET',
87
-            'query'  => array(
88
-                'route_id'             => $routeId,
89
-                'route_destination_id' => $addressId,
90
-            )
91
-        ));
92
-
93
-        return Address::fromArray($address);
94
-    }
95
-
96
-    public function update()
97
-    {
98
-        $address = Route4Me::makeRequst(array(
99
-            'url'    => self::$apiUrl,
100
-            'method' => 'PUT',
101
-            'body'   => $this->toArray(),
102
-            'query'  => array(
103
-                'route_id'             => $this->route_id,
104
-                'route_destination_id' => $this->route_destination_id,
105
-            ),
106
-        ));
107
-
108
-        return Address::fromArray($address);
109
-    }
96
+	public function update()
97
+	{
98
+		$address = Route4Me::makeRequst(array(
99
+			'url'    => self::$apiUrl,
100
+			'method' => 'PUT',
101
+			'body'   => $this->toArray(),
102
+			'query'  => array(
103
+				'route_id'             => $this->route_id,
104
+				'route_destination_id' => $this->route_destination_id,
105
+			),
106
+		));
107
+
108
+		return Address::fromArray($address);
109
+	}
110 110
 	
111 111
 	public function markAddress($params, $body)
112
-    {
113
-        $result = Route4Me::makeRequst(array(
114
-            'url'    => self::$apiUrl,
115
-            'method' => 'PUT',
116
-            'query'  => array(
117
-                'route_id'  => isset($params['route_id']) ? $params['route_id']: null, 
118
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
119
-            ),
120
-            'body'   => $body
121
-        ));
122
-
123
-        return $result;
124
-    }
112
+	{
113
+		$result = Route4Me::makeRequst(array(
114
+			'url'    => self::$apiUrl,
115
+			'method' => 'PUT',
116
+			'query'  => array(
117
+				'route_id'  => isset($params['route_id']) ? $params['route_id']: null, 
118
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
119
+			),
120
+			'body'   => $body
121
+		));
122
+
123
+		return $result;
124
+	}
125 125
 	
126 126
 	public function markAsDeparted($params)
127 127
 	{
128 128
 		$address = Route4Me::makeRequst(array(
129
-            'url'    => self::$apiUrDeparted,
130
-            'method' => 'GET',
131
-            'query'  => array(
132
-                'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
133
-                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
134
-                'is_departed'   => isset($params['is_departed']) ? $params['is_departed']: null,
135
-                'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
136
-            ),
137
-        ));
138
-
139
-        return $address;
129
+			'url'    => self::$apiUrDeparted,
130
+			'method' => 'GET',
131
+			'query'  => array(
132
+				'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
133
+				'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
134
+				'is_departed'   => isset($params['is_departed']) ? $params['is_departed']: null,
135
+				'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
136
+			),
137
+		));
138
+
139
+		return $address;
140 140
 	}
141 141
 	
142 142
 	public function markAsVisited($params)
143 143
 	{
144 144
 		$address = Route4Me::makeRequst(array(
145
-            'url'    => self::$apiUrVisited,
146
-            'method' => 'GET',
147
-            'query'  => array(
148
-                'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
149
-                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
150
-                'is_visited'   => isset($params['is_visited']) ? $params['is_visited']: null,
151
-                'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
152
-            ),
153
-        ));
154
-
155
-        return $address;
145
+			'url'    => self::$apiUrVisited,
146
+			'method' => 'GET',
147
+			'query'  => array(
148
+				'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
149
+				'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
150
+				'is_visited'   => isset($params['is_visited']) ? $params['is_visited']: null,
151
+				'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
152
+			),
153
+		));
154
+
155
+		return $address;
156 156
 	}
157 157
 
158
-    public function delete()
159
-    {
160
-        $address = Route4Me::makeRequst(array(
161
-            'url'    => self::$apiUrl,
162
-            'method' => 'DELETE',
163
-            'query'  => array(
164
-                'route_id'             => $this->route_id,
165
-                'route_destination_id' => $this->route_destination_id,
166
-            )
167
-        ));
168
-
169
-        return (bool)$address['deleted'];
170
-    }
158
+	public function delete()
159
+	{
160
+		$address = Route4Me::makeRequst(array(
161
+			'url'    => self::$apiUrl,
162
+			'method' => 'DELETE',
163
+			'query'  => array(
164
+				'route_id'             => $this->route_id,
165
+				'route_destination_id' => $this->route_destination_id,
166
+			)
167
+		));
168
+
169
+		return (bool)$address['deleted'];
170
+	}
171 171
 	
172 172
 	public function MoveDestinationToRoute($params)
173 173
 	{
174 174
 		$result = Route4Me::makeRequst(array(
175
-            'url'    => self::$apiUrlMove,
176
-            'method' => 'POST',
177
-            'query'  => array(
178
-                'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null,
179
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
180
-                'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
181
-            )
182
-        ));
183
-
184
-        return $result;
175
+			'url'    => self::$apiUrlMove,
176
+			'method' => 'POST',
177
+			'query'  => array(
178
+				'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null,
179
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
180
+				'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
181
+			)
182
+		));
183
+
184
+		return $result;
185 185
 		
186 186
 	}
187 187
 
188
-    function getAddressId()
189
-    {
190
-        return $this->route_destination_id;
191
-    }
188
+	function getAddressId()
189
+	{
190
+		return $this->route_destination_id;
191
+	}
192 192
 }
Please login to merge, or discard this patch.
src/Route4Me/TrackSetParams.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -9,102 +9,102 @@
 block discarded – undo
9 9
 
10 10
 class TrackSetParams extends Common
11 11
 {
12
-    public $format;
13
-    public $member_id;
14
-    public $route_id;
15
-    public $tx_id;
16
-    public $vehicle_id;
17
-    public $course;
18
-    public $speed;
19
-    public $lat;
20
-    public $lng;
21
-    public $altitude;
22
-    public $device_type;
23
-    public $device_guid;
24
-    public $device_timestamp;
25
-    public $app_version;
26
-
27
-    public static function fromArray(array $params)
28
-    {
29
-        $param = new TrackSetParams;
30
-
31
-        if (!isset($params['format'])) {
32
-            throw new BadParam("format must be provided.");
33
-        }
34
-
35
-        $types = array(
36
-            Format::SERIALIZED,
37
-            Format::CSV,
38
-            Format::XML
39
-        );
40
-        if (!in_array($params['format'], $types)) {
41
-            throw new BadParam("format is invalid.");
42
-        }
43
-
44
-        if (!isset($params['route_id'])) {
45
-            throw new BadParam("route_id must be provided.");
46
-        }
47
-
48
-        if (!isset($params['member_id'])) {
49
-            throw new BadParam("member_id must be provided.");
50
-        }
51
-
52
-        if (!isset($params['course'])) {
53
-            throw new BadParam("course must be provided.");
54
-        }
55
-
56
-        if (!isset($params['speed'])) {
57
-            throw new BadParam("speed must be provided.");
58
-        }
59
-
60
-        if (!isset($params['lat'])) {
61
-            throw new BadParam("lat must be provided.");
62
-        }
63
-
64
-        if (!isset($params['lng'])) {
65
-            throw new BadParam("lng must be provided.");
66
-        }
67
-
68
-        if (!isset($params['device_type'])) {
69
-            throw new BadParam("device_type must be provided.");
70
-        }
71
-
72
-        $deviceTypes = array(
73
-            DeviceType::IPHONE,
74
-            DeviceType::IPAD,
75
-            DeviceType::ANDROID_PHONE,
76
-            DeviceType::ANDROID_TABLET
77
-        );
78
-        if (!in_array($params['device_type'], $deviceTypes)) {
79
-            throw new BadParam("device_type is invalid.");
80
-        }
81
-
82
-        if (!isset($params['device_guid'])) {
83
-            throw new BadParam("device_guid must be provided.");
84
-        }
85
-
86
-        if (isset($params['device_timestamp'])) {
87
-            $template = '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/i';
88
-            if (!preg_match($template, $params['device_timestamp'])) {
89
-                throw new BadParam("device_timestamp is invalid.");
90
-            }
91
-        }
92
-
93
-        $param->format = self::getValue($params, 'format');
94
-        $param->route_id = self::getValue($params, 'route_id');
95
-        $param->member_id = self::getValue($params, 'member_id');
96
-        $param->course = self::getValue($params, 'course');
97
-        $param->speed = self::getValue($params, 'speed');
98
-        $param->lat = self::getValue($params, 'lat');
99
-        $param->lng = self::getValue($params, 'lng');
100
-        $param->device_type = self::getValue($params, 'device_type');
101
-        $param->device_guid = self::getValue($params, 'device_guid');
102
-        $param->device_timestamp = self::getValue($params, 'device_timestamp');
103
-        $param->vehicle_id = self::getValue($params, 'vehicle_id');
104
-        $param->altitude = self::getValue($params, 'altitude');
105
-        $param->app_version = self::getValue($params, 'app_version');
106
-        $param->tx_id = self::getValue($params, 'tx_id');
107
-
108
-        return $param;
109
-    }
12
+	public $format;
13
+	public $member_id;
14
+	public $route_id;
15
+	public $tx_id;
16
+	public $vehicle_id;
17
+	public $course;
18
+	public $speed;
19
+	public $lat;
20
+	public $lng;
21
+	public $altitude;
22
+	public $device_type;
23
+	public $device_guid;
24
+	public $device_timestamp;
25
+	public $app_version;
26
+
27
+	public static function fromArray(array $params)
28
+	{
29
+		$param = new TrackSetParams;
30
+
31
+		if (!isset($params['format'])) {
32
+			throw new BadParam("format must be provided.");
33
+		}
34
+
35
+		$types = array(
36
+			Format::SERIALIZED,
37
+			Format::CSV,
38
+			Format::XML
39
+		);
40
+		if (!in_array($params['format'], $types)) {
41
+			throw new BadParam("format is invalid.");
42
+		}
43
+
44
+		if (!isset($params['route_id'])) {
45
+			throw new BadParam("route_id must be provided.");
46
+		}
47
+
48
+		if (!isset($params['member_id'])) {
49
+			throw new BadParam("member_id must be provided.");
50
+		}
51
+
52
+		if (!isset($params['course'])) {
53
+			throw new BadParam("course must be provided.");
54
+		}
55
+
56
+		if (!isset($params['speed'])) {
57
+			throw new BadParam("speed must be provided.");
58
+		}
59
+
60
+		if (!isset($params['lat'])) {
61
+			throw new BadParam("lat must be provided.");
62
+		}
63
+
64
+		if (!isset($params['lng'])) {
65
+			throw new BadParam("lng must be provided.");
66
+		}
67
+
68
+		if (!isset($params['device_type'])) {
69
+			throw new BadParam("device_type must be provided.");
70
+		}
71
+
72
+		$deviceTypes = array(
73
+			DeviceType::IPHONE,
74
+			DeviceType::IPAD,
75
+			DeviceType::ANDROID_PHONE,
76
+			DeviceType::ANDROID_TABLET
77
+		);
78
+		if (!in_array($params['device_type'], $deviceTypes)) {
79
+			throw new BadParam("device_type is invalid.");
80
+		}
81
+
82
+		if (!isset($params['device_guid'])) {
83
+			throw new BadParam("device_guid must be provided.");
84
+		}
85
+
86
+		if (isset($params['device_timestamp'])) {
87
+			$template = '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/i';
88
+			if (!preg_match($template, $params['device_timestamp'])) {
89
+				throw new BadParam("device_timestamp is invalid.");
90
+			}
91
+		}
92
+
93
+		$param->format = self::getValue($params, 'format');
94
+		$param->route_id = self::getValue($params, 'route_id');
95
+		$param->member_id = self::getValue($params, 'member_id');
96
+		$param->course = self::getValue($params, 'course');
97
+		$param->speed = self::getValue($params, 'speed');
98
+		$param->lat = self::getValue($params, 'lat');
99
+		$param->lng = self::getValue($params, 'lng');
100
+		$param->device_type = self::getValue($params, 'device_type');
101
+		$param->device_guid = self::getValue($params, 'device_guid');
102
+		$param->device_timestamp = self::getValue($params, 'device_timestamp');
103
+		$param->vehicle_id = self::getValue($params, 'vehicle_id');
104
+		$param->altitude = self::getValue($params, 'altitude');
105
+		$param->app_version = self::getValue($params, 'app_version');
106
+		$param->tx_id = self::getValue($params, 'tx_id');
107
+
108
+		return $param;
109
+	}
110 110
 }
Please login to merge, or discard this patch.
src/Route4Me/Vehicle.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,21 +11,21 @@
 block discarded – undo
11 11
 		
12 12
 		public static function fromArray(array $params) {
13 13
 			$vehicle= new Vehicle();
14
-	        foreach($params as $key => $value) {
15
-	            if (property_exists($vehicle, $key)) {
16
-	                $vehicle->{$key} = $value;
17
-	            }
14
+			foreach($params as $key => $value) {
15
+				if (property_exists($vehicle, $key)) {
16
+					$vehicle->{$key} = $value;
17
+				}
18 18
 			}
19 19
 			
20 20
 			return $order;
21 21
 		}
22 22
 		
23 23
 		public static function getVehicles()
24
-	    {
25
-	    	$response = Route4Me::makeRequst(array(
26
-	            'url'    => self::$apiUrl,
27
-	            'method' => 'GET'
28
-	        ));
24
+		{
25
+			$response = Route4Me::makeRequst(array(
26
+				'url'    => self::$apiUrl,
27
+				'method' => 'GET'
28
+			));
29 29
 
30 30
 			return $response;
31 31
 		}
Please login to merge, or discard this patch.
src/Route4Me/Territory.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -21,94 +21,94 @@
 block discarded – undo
21 21
 		
22 22
 		public static function fromArray(array $params) {
23 23
 			if (!isset($params['territory_name'])) {
24
-	            throw new BadParam('Territory name must be provided');
25
-	        }
24
+				throw new BadParam('Territory name must be provided');
25
+			}
26 26
 			
27 27
 			if (!isset($params['territory_color'])) {
28
-	            throw new BadParam('Territory color must be provided');
29
-	        }
28
+				throw new BadParam('Territory color must be provided');
29
+			}
30 30
 			
31 31
 			if (!isset($params['territory'])) {
32
-	            throw new BadParam('Territory must be provided');
33
-	        }
32
+				throw new BadParam('Territory must be provided');
33
+			}
34 34
 			
35 35
 			$territoryparameters = new Territory();
36
-	        foreach($params as $key => $value) {
37
-	            if (property_exists($territoryparameters, $key)) {
38
-	                $territoryparameters->{$key} = $value;
39
-	            }
36
+			foreach($params as $key => $value) {
37
+				if (property_exists($territoryparameters, $key)) {
38
+					$territoryparameters->{$key} = $value;
39
+				}
40 40
 			}
41 41
 			
42 42
 			return $territoryparameters;
43 43
 		}
44 44
 		
45 45
 		public static function getTerritory($params)
46
-	    {
47
-	        $territory = Route4Me::makeRequst(array(
48
-	            'url'    => self::$apiUrl,
49
-	            'method' => 'GET',
50
-	            'query'  => array(
51
-	                'territory_id' => isset($params['territory_id']) ? $params['territory_id']: null,
52
-	                'addresses' => isset($params['addresses']) ? $params['addresses']: null,
53
-	            )
54
-	        ));
46
+		{
47
+			$territory = Route4Me::makeRequst(array(
48
+				'url'    => self::$apiUrl,
49
+				'method' => 'GET',
50
+				'query'  => array(
51
+					'territory_id' => isset($params['territory_id']) ? $params['territory_id']: null,
52
+					'addresses' => isset($params['addresses']) ? $params['addresses']: null,
53
+				)
54
+			));
55 55
 	
56
-	        return $territory;
57
-	    }
56
+			return $territory;
57
+		}
58 58
 		
59 59
 		public static function getTerritories($params)
60
-	    {
61
-	        $response = Route4Me::makeRequst(array(
62
-	            'url'    => self::$apiUrl,
63
-	            'method' => 'GET',
64
-	            'query'  => array(
65
-	                'offset'  => isset($params->offset) ? $params->offset: null,
66
-	                'limit'   => isset($params->limit) ? $params->limit: null,
67
-	            )
68
-	        ));
60
+		{
61
+			$response = Route4Me::makeRequst(array(
62
+				'url'    => self::$apiUrl,
63
+				'method' => 'GET',
64
+				'query'  => array(
65
+					'offset'  => isset($params->offset) ? $params->offset: null,
66
+					'limit'   => isset($params->limit) ? $params->limit: null,
67
+				)
68
+			));
69 69
 	
70
-	        return $response;
71
-	    }
70
+			return $response;
71
+		}
72 72
 
73 73
 		public static function addTerritory($params)
74
-	    {
75
-	    	$response = Route4Me::makeRequst(array(
76
-	            'url'    => self::$apiUrl,
77
-	            'method' => 'ADD',
78
-	            'query'  => array(
79
-	            	'territory_name' => isset($params->territory_name) ? $params->territory_name: null,
80
-	                'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
81
-	                'territory' => isset($params->territory) ? $params->territory : null,
82
-	            )
83
-	        ));
74
+		{
75
+			$response = Route4Me::makeRequst(array(
76
+				'url'    => self::$apiUrl,
77
+				'method' => 'ADD',
78
+				'query'  => array(
79
+					'territory_name' => isset($params->territory_name) ? $params->territory_name: null,
80
+					'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
81
+					'territory' => isset($params->territory) ? $params->territory : null,
82
+				)
83
+			));
84 84
 
85 85
 			return $response;
86 86
 		}
87 87
 		
88 88
 		public function deleteTerritory($territory_id)
89
-	    {
90
-	        $result = Route4Me::makeRequst(array(
91
-	            'url'    => self::$apiUrl,
92
-	            'method' => 'DELETEARRAY',
93
-	            'query'  => array(
94
-	                'territory_id'  => $territory_id
95
-	            )
96
-	        ));
89
+		{
90
+			$result = Route4Me::makeRequst(array(
91
+				'url'    => self::$apiUrl,
92
+				'method' => 'DELETEARRAY',
93
+				'query'  => array(
94
+					'territory_id'  => $territory_id
95
+				)
96
+			));
97 97
 	
98
-	        return $result;
99
-	    }
98
+			return $result;
99
+		}
100 100
 		
101 101
 		public function updateTerritory($params)
102
-	    {
103
-	        $response = Route4Me::makeRequst(array(
104
-	            'url'    => self::$apiUrl,
105
-	            'method' => 'PUT',
106
-	            'query'   => (array)$params,
102
+		{
103
+			$response = Route4Me::makeRequst(array(
104
+				'url'    => self::$apiUrl,
105
+				'method' => 'PUT',
106
+				'query'   => (array)$params,
107 107
 
108
-	        ));
108
+			));
109 109
 	
110
-	        return $response;
111
-	    }
110
+			return $response;
111
+		}
112 112
 	}
113 113
 	
114 114
 ?>
115 115
\ No newline at end of file
Please login to merge, or discard this patch.