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.
Passed
Push — master ( 39430a...e623a9 )
by Oleg
02:28
created
src/Route4Me/Route.php 3 patches
Indentation   +274 added lines, -274 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,21 +22,21 @@  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
 	public $is_unrouted;
@@ -44,101 +44,101 @@  discard block
 block discarded – undo
44 44
 	public $dev_lat;
45 45
 	public $dev_lng;
46 46
 
47
-    public static function fromArray(array $params) 
48
-    {
49
-        $route = new Route();
50
-        $route->route_id = Common::getValue($params, 'route_id');
51
-        $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
52
-        $route->vehicle_alias = Common::getValue($params, 'vehicle_alias');
53
-        $route->driver_alias = Common::getValue($params, 'driver_alias');
54
-        $route->trip_distance = Common::getValue($params, 'trip_distance');
55
-        $route->mpg = Common::getValue($params, 'mpg');
56
-        $route->gas_price = Common::getValue($params, 'gas_price');
57
-        $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec');
58
-        $route->is_unrouted = Common::getvalue($params, 'is_unrouted');
59
-
60
-        // Make RouteParameters
61
-        if (isset($params['parameters'])) {
62
-            $route->parameters = RouteParameters::fromArray($params['parameters']);
63
-        }
64
-
65
-        if (isset($params['addresses'])) {
66
-            $addresses = array();
67
-            foreach ($params['addresses'] as $address) {
68
-                $addresses[] = Address::fromArray($address);
69
-            }
70
-
71
-            $route->addresses = $addresses;
72
-        }
73
-
74
-        $route->links = Common::getValue($params, 'links', array());
75
-        $route->directions = Common::getValue($params, 'directions', array());
76
-        $route->path = Common::getValue($params, 'path', array());
77
-        $route->tracking_history = Common::getValue($params, 'tracking_history', array());
78
-
79
-        return $route;
80
-    }
81
-
82
-    public static function getRoutes($routeId=null, $params=null)
83
-    {
84
-        $query = array(
85
-            'api_key' => Route4Me::getApiKey()
86
-        );
87
-
88
-        if ($routeId) {
89
-            $query['route_id'] = implode(',', (array) $routeId);
90
-        }
91
-
92
-        if ($params) {
93
-            if (isset($params['directions'])) {
94
-                $query['directions'] = $params['directions'];
95
-            }
96
-
97
-            if (isset($params['route_path_output'])) {
98
-                $query['route_path_output'] = $params['route_path_output'];
99
-            }
100
-
101
-            if (isset($params['device_tracking_history'])) {
102
-                $query['device_tracking_history'] = $params['device_tracking_history'];
103
-            }
47
+	public static function fromArray(array $params) 
48
+	{
49
+		$route = new Route();
50
+		$route->route_id = Common::getValue($params, 'route_id');
51
+		$route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
52
+		$route->vehicle_alias = Common::getValue($params, 'vehicle_alias');
53
+		$route->driver_alias = Common::getValue($params, 'driver_alias');
54
+		$route->trip_distance = Common::getValue($params, 'trip_distance');
55
+		$route->mpg = Common::getValue($params, 'mpg');
56
+		$route->gas_price = Common::getValue($params, 'gas_price');
57
+		$route->route_duration_sec = Common::getvalue($params, 'route_duration_sec');
58
+		$route->is_unrouted = Common::getvalue($params, 'is_unrouted');
59
+
60
+		// Make RouteParameters
61
+		if (isset($params['parameters'])) {
62
+			$route->parameters = RouteParameters::fromArray($params['parameters']);
63
+		}
64
+
65
+		if (isset($params['addresses'])) {
66
+			$addresses = array();
67
+			foreach ($params['addresses'] as $address) {
68
+				$addresses[] = Address::fromArray($address);
69
+			}
70
+
71
+			$route->addresses = $addresses;
72
+		}
73
+
74
+		$route->links = Common::getValue($params, 'links', array());
75
+		$route->directions = Common::getValue($params, 'directions', array());
76
+		$route->path = Common::getValue($params, 'path', array());
77
+		$route->tracking_history = Common::getValue($params, 'tracking_history', array());
78
+
79
+		return $route;
80
+	}
81
+
82
+	public static function getRoutes($routeId=null, $params=null)
83
+	{
84
+		$query = array(
85
+			'api_key' => Route4Me::getApiKey()
86
+		);
87
+
88
+		if ($routeId) {
89
+			$query['route_id'] = implode(',', (array) $routeId);
90
+		}
91
+
92
+		if ($params) {
93
+			if (isset($params['directions'])) {
94
+				$query['directions'] = $params['directions'];
95
+			}
96
+
97
+			if (isset($params['route_path_output'])) {
98
+				$query['route_path_output'] = $params['route_path_output'];
99
+			}
100
+
101
+			if (isset($params['device_tracking_history'])) {
102
+				$query['device_tracking_history'] = $params['device_tracking_history'];
103
+			}
104 104
 			
105 105
 			if (isset($params['query'])) {
106
-                $query['query'] = $params['query'];
107
-            }
106
+				$query['query'] = $params['query'];
107
+			}
108 108
 
109
-            $query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
110
-            $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
111
-        }
112
-
113
-        $json = Route4Me::makeRequst(array(
114
-            'url'    => self::$apiUrl,
115
-            'method' => 'GET',
116
-            'query'  => $query
117
-        ));
109
+			$query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
110
+			$query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
111
+		}
118 112
 
119
-        if ($routeId) {
120
-            return Route::fromArray($json); die("");
121
-        } else {
122
-            $routes = array();
123
-            foreach($json as $route) {
124
-                $routes[] = Route::fromArray($route);
125
-            }
126
-            return $routes;
127
-        }
128
-    }
113
+		$json = Route4Me::makeRequst(array(
114
+			'url'    => self::$apiUrl,
115
+			'method' => 'GET',
116
+			'query'  => $query
117
+		));
118
+
119
+		if ($routeId) {
120
+			return Route::fromArray($json); die("");
121
+		} else {
122
+			$routes = array();
123
+			foreach($json as $route) {
124
+				$routes[] = Route::fromArray($route);
125
+			}
126
+			return $routes;
127
+		}
128
+	}
129 129
 
130 130
 	public function getRoutePoints($routeId, $params)
131 131
 	{
132 132
 		$result = Route4Me::makeRequst(array(
133
-            'url'    => self::$apiUrl,
134
-            'method' => 'GET',
135
-            'query'  => array(
136
-            	'api_key' => Route4Me::getApiKey(),
137
-                'route_id' => $routeId,
138
-                'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null,
139
-                'directions' => isset($params['directions']) ? $params['directions'] : null,
140
-            )
141
-        ));
133
+			'url'    => self::$apiUrl,
134
+			'method' => 'GET',
135
+			'query'  => array(
136
+				'api_key' => Route4Me::getApiKey(),
137
+				'route_id' => $routeId,
138
+				'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null,
139
+				'directions' => isset($params['directions']) ? $params['directions'] : null,
140
+			)
141
+		));
142 142
 
143 143
 		return $result;
144 144
 	}
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 	public function duplicateRoute($route_id)
147 147
 	{
148 148
 		$result = Route4Me::makeRequst(array(
149
-            'url'    => self::$apiUrlDuplicate,
150
-            'method' => 'GET',
151
-            'query'  => array(
152
-            	'api_key' => Route4Me::getApiKey(),
153
-                'route_id' => $route_id,
154
-                'to' => 'none',
155
-            )
156
-        ));
149
+			'url'    => self::$apiUrlDuplicate,
150
+			'method' => 'GET',
151
+			'query'  => array(
152
+				'api_key' => Route4Me::getApiKey(),
153
+				'route_id' => $route_id,
154
+				'to' => 'none',
155
+			)
156
+		));
157 157
 		
158 158
 		return $result;
159 159
 	}
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
 	public function resequenceRoute($params)
162 162
 	{
163 163
 		$result = Route4Me::makeRequst(array(
164
-            'url'    => self::$apiUrl,
165
-            'method' => 'PUT',
166
-            'query'  => array(
167
-            	'api_key' => Route4Me::getApiKey(),
168
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
169
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
170
-            ),
171
-            'body'  => array(
164
+			'url'    => self::$apiUrl,
165
+			'method' => 'PUT',
166
+			'query'  => array(
167
+				'api_key' => Route4Me::getApiKey(),
168
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
169
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
170
+			),
171
+			'body'  => array(
172 172
 				'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
173 173
 			)
174
-        ));
174
+		));
175 175
 		
176 176
 		return $result;
177 177
 	}
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 	public function resequenceAllAddresses($params)
180 180
 	{
181 181
 		$result = Route4Me::makeRequst(array(
182
-            'url'    => self::$apiUrlReseq,
183
-            'method' => 'GET',
184
-            'query'  => array(
185
-            	'api_key' => Route4Me::getApiKey(),
186
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
187
-                'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null,
188
-                'optimize' => isset($params['optimize']) ? $params['optimize'] : null,
189
-            )
190
-        ));
182
+			'url'    => self::$apiUrlReseq,
183
+			'method' => 'GET',
184
+			'query'  => array(
185
+				'api_key' => Route4Me::getApiKey(),
186
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
187
+				'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null,
188
+				'optimize' => isset($params['optimize']) ? $params['optimize'] : null,
189
+			)
190
+		));
191 191
 		
192 192
 		return $result;
193 193
 		
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 	public function mergeRoutes($params)
197 197
 	{
198 198
 		$result = Route4Me::makeRequst(array(
199
-            'url'    => self::$apiUrlMerge,
200
-            'method' => 'POST',
201
-            'query'  => array(
202
-            	'api_key' => Route4Me::getApiKey(),
203
-            ),
204
-            'body'  => array(
199
+			'url'    => self::$apiUrlMerge,
200
+			'method' => 'POST',
201
+			'query'  => array(
202
+				'api_key' => Route4Me::getApiKey(),
203
+			),
204
+			'body'  => array(
205 205
 				'route_ids' => isset($params['route_ids']) ? $params['route_ids'] : null,
206 206
 			),
207 207
 			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
208
-        ));
208
+		));
209 209
 		
210 210
 		return $result;
211 211
 	}
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
 	public function shareRoute($params)
214 214
 	{
215 215
 		$result = Route4Me::makeRequst(array(
216
-            'url'    => self::$apiUrlShare,
217
-            'method' => 'POST',
218
-            'query'  => array(
219
-            	'api_key' => Route4Me::getApiKey(),
220
-            	'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
221
-            ),
222
-            'body'  => array(
216
+			'url'    => self::$apiUrlShare,
217
+			'method' => 'POST',
218
+			'query'  => array(
219
+				'api_key' => Route4Me::getApiKey(),
220
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
221
+			),
222
+			'body'  => array(
223 223
 				'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null,
224 224
 			),
225 225
 			'Content-Type' => 'multipart/form-data'
226
-        ));
226
+		));
227 227
 		
228 228
 		return $result;
229 229
 	}
@@ -232,98 +232,98 @@  discard block
 block discarded – undo
232 232
 	public function getRandomRouteId($offset,$limit)
233 233
 	{
234 234
 		$query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
235
-        $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
235
+		$query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
236 236
 			
237 237
 		$json = Route4Me::makeRequst(array(
238
-            'url'    => self::$apiUrl,
239
-            'method' => 'GET',
240
-            'query'  => $query
241
-        ));
238
+			'url'    => self::$apiUrl,
239
+			'method' => 'GET',
240
+			'query'  => $query
241
+		));
242 242
         
243
-        if (sizeof($json)>0) {
244
-            $routes = array();
245
-            foreach($json as $route) {
246
-                $routes[] = Route::fromArray($route);
247
-            }
243
+		if (sizeof($json)>0) {
244
+			$routes = array();
245
+			foreach($json as $route) {
246
+				$routes[] = Route::fromArray($route);
247
+			}
248 248
             
249
-            $num=rand(0,sizeof($routes)-1);
250
-            $rRoute=(array)$routes[$num];
249
+			$num=rand(0,sizeof($routes)-1);
250
+			$rRoute=(array)$routes[$num];
251 251
             
252
-            if (is_array($rRoute)) 
253
-            {
254
-                return $rRoute["route_id"];
255
-            }
256
-            else return null;
257
-        } else return null;
252
+			if (is_array($rRoute)) 
253
+			{
254
+				return $rRoute["route_id"];
255
+			}
256
+			else return null;
257
+		} else return null;
258 258
 		
259 259
 		
260 260
 	}
261 261
 
262
-    public function update()
263
-    {
264
-        $route = Route4Me::makeRequst(array(
265
-            'url'    => self::$apiUrl,
266
-            'method' => 'PUT',
267
-            'query'  => array(
268
-                'route_id' => isset($this->route_id) ? $this->route_id : null,
269
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
270
-            ),
271
-            'body' => array (
272
-            	'parameters' => $this->parameters,
273
-            	),
274
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
275
-        ));
262
+	public function update()
263
+	{
264
+		$route = Route4Me::makeRequst(array(
265
+			'url'    => self::$apiUrl,
266
+			'method' => 'PUT',
267
+			'query'  => array(
268
+				'route_id' => isset($this->route_id) ? $this->route_id : null,
269
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
270
+			),
271
+			'body' => array (
272
+				'parameters' => $this->parameters,
273
+				),
274
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
275
+		));
276 276
 
277
-        return Route::fromArray($route);
278
-    }
277
+		return Route::fromArray($route);
278
+	}
279 279
 	
280 280
 	public function updateAddress()
281
-    {
282
-        $result = Route4Me::makeRequst(array(
283
-            'url'    => self::$apiUrlAddress,
284
-            'method' => 'PUT',
285
-            'query'  => array(
286
-                'route_id' => isset($this->route_id) ? $this->route_id : null,
287
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
288
-            ),
289
-            'body' => get_object_vars($this->parameters),
290
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
291
-        ));
281
+	{
282
+		$result = Route4Me::makeRequst(array(
283
+			'url'    => self::$apiUrlAddress,
284
+			'method' => 'PUT',
285
+			'query'  => array(
286
+				'route_id' => isset($this->route_id) ? $this->route_id : null,
287
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
288
+			),
289
+			'body' => get_object_vars($this->parameters),
290
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
291
+		));
292 292
 
293
-        return $result;
294
-    }
293
+		return $result;
294
+	}
295 295
 
296
-    public function addAddresses(array $params)
297
-    {
298
-        $route = Route4Me::makeRequst(array(
299
-            'url'    => self::$apiUrl,
300
-            'method' => 'PUT',
301
-            'query'  => array(
302
-            	'api_key' => Route4Me::getApiKey(),
303
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
304
-                'addresses' => isset($params['addresses']) ? $params['addresses'] : null
305
-            )
306
-        ));
296
+	public function addAddresses(array $params)
297
+	{
298
+		$route = Route4Me::makeRequst(array(
299
+			'url'    => self::$apiUrl,
300
+			'method' => 'PUT',
301
+			'query'  => array(
302
+				'api_key' => Route4Me::getApiKey(),
303
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
304
+				'addresses' => isset($params['addresses']) ? $params['addresses'] : null
305
+			)
306
+		));
307 307
 
308
-        return Route::fromArray($route);
309
-    }
308
+		return Route::fromArray($route);
309
+	}
310 310
 	
311 311
 	public function insertAddressOptimalPosition(array $params)
312 312
 	{
313 313
 		$route = Route4Me::makeRequst(array(
314
-            'url'    => self::$apiUrl,
315
-            'method' => 'PUT',
316
-            'query'  => array(
317
-            	'api_key' => Route4Me::getApiKey(),
318
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
319
-            ),
320
-            'body'  => array(
314
+			'url'    => self::$apiUrl,
315
+			'method' => 'PUT',
316
+			'query'  => array(
317
+				'api_key' => Route4Me::getApiKey(),
318
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
319
+			),
320
+			'body'  => array(
321 321
 				'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
322 322
 				'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null,
323 323
 			)
324
-        ));
324
+		));
325 325
 
326
-        return Route::fromArray($route);
326
+		return Route::fromArray($route);
327 327
 	}
328 328
 	
329 329
 	public function addNoteFile($params)
@@ -332,18 +332,18 @@  discard block
 block discarded – undo
332 332
 		$rpath = realpath($fname);
333 333
 		//echo $rpath;die("");
334 334
 		$result= Route4Me::makeRequst(array(
335
-            'url'    => self::$apiUrlNoteFile,
336
-            'method' => 'POST',
337
-            'query'  => array(
338
-            	'api_key' => Route4Me::getApiKey(),
339
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
340
-                'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
341
-                'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null,
342
-                'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null,
343
-                'device_type' => isset($params['device_type']) ? $params['device_type'] : null,
344
-                'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null,
345
-            ),
346
-            'body'  => array(
335
+			'url'    => self::$apiUrlNoteFile,
336
+			'method' => 'POST',
337
+			'query'  => array(
338
+				'api_key' => Route4Me::getApiKey(),
339
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
340
+				'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
341
+				'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null,
342
+				'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null,
343
+				'device_type' => isset($params['device_type']) ? $params['device_type'] : null,
344
+				'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null,
345
+			),
346
+			'body'  => array(
347 347
 				'strUpdateType' => isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
348 348
 				'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null,
349 349
 				'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
@@ -353,18 +353,18 @@  discard block
 block discarded – undo
353 353
 			'HTTPHEADER' => array(
354 354
 				'Content-Type: application/x-www-form-urlencoded'
355 355
 			)
356
-        ));
356
+		));
357 357
 
358
-        return $result;
358
+		return $result;
359 359
 	}
360 360
 
361
-    public function delete($route_id)
362
-    {
363
-        $result = Route4Me::makeRequst(array(
364
-            'url'    => self::$apiUrl,
365
-            'method' => 'DELETE',
366
-            'query'  => array( 'route_id' => $route_id )
367
-        ));
361
+	public function delete($route_id)
362
+	{
363
+		$result = Route4Me::makeRequst(array(
364
+			'url'    => self::$apiUrl,
365
+			'method' => 'DELETE',
366
+			'query'  => array( 'route_id' => $route_id )
367
+		));
368 368
 		
369 369
 		// The code below doesn't work, altough this method is described as workable in REST API 
370 370
 		/*
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
             )
378 378
         ));
379 379
 		*/
380
-        return $result;
381
-    }
380
+		return $result;
381
+	}
382 382
 	
383 383
 	public function GetAddressesFromRoute($route_id)
384 384
 	{
@@ -402,63 +402,63 @@  discard block
 block discarded – undo
402 402
 		} else { return null;}
403 403
 	}
404 404
 
405
-    public function getRouteId()
406
-    {
407
-        return $this->route_id;
408
-    }
405
+	public function getRouteId()
406
+	{
407
+		return $this->route_id;
408
+	}
409 409
 
410
-    public function getOptimizationId()
411
-    {
412
-        return $this->optimization_problem_id;
413
-    }
410
+	public function getOptimizationId()
411
+	{
412
+		return $this->optimization_problem_id;
413
+	}
414 414
 	
415 415
 	public function GetLastLocation(array $params)
416 416
 	{
417 417
 		$route = Route4Me::makeRequst(array(
418
-            'url'    => self::$apiUrl,
419
-            'method' => 'GET',
420
-            'query'  => array(
421
-            	'api_key' => Route4Me::getApiKey(),
422
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
423
-                'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null
424
-            )
425
-        ));
418
+			'url'    => self::$apiUrl,
419
+			'method' => 'GET',
420
+			'query'  => array(
421
+				'api_key' => Route4Me::getApiKey(),
422
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
423
+				'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null
424
+			)
425
+		));
426 426
 
427
-        return Route::fromArray($route);
427
+		return Route::fromArray($route);
428 428
 		
429 429
 	}
430 430
 	
431 431
 	public function GetTrackingHistoryFromTimeRange(array $params)
432 432
 	{
433 433
 		$route = Route4Me::makeRequst(array(
434
-            'url'    => self::$apiUrlDeviceLocation,
435
-            'method' => 'GET',
436
-            'query'  => array(
437
-            	'api_key' => Route4Me::getApiKey(),
438
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
439
-                'format' => isset($params['format']) ? $params['format'] : null,
440
-                'time_period' => isset($params['time_period']) ? $params['time_period'] : null,
441
-                'start_date' => isset($params['start_date']) ? $params['start_date'] : null,
442
-                'end_date' => isset($params['end_date']) ? $params['end_date'] : null
443
-                )
444
-        ));
445
-
446
-        return $route;
434
+			'url'    => self::$apiUrlDeviceLocation,
435
+			'method' => 'GET',
436
+			'query'  => array(
437
+				'api_key' => Route4Me::getApiKey(),
438
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
439
+				'format' => isset($params['format']) ? $params['format'] : null,
440
+				'time_period' => isset($params['time_period']) ? $params['time_period'] : null,
441
+				'start_date' => isset($params['start_date']) ? $params['start_date'] : null,
442
+				'end_date' => isset($params['end_date']) ? $params['end_date'] : null
443
+				)
444
+		));
445
+
446
+		return $route;
447 447
 		
448 448
 	}
449 449
 	
450 450
 	public function GetAssetTracking(array $params)
451 451
 	{
452 452
 		$route = Route4Me::makeRequst(array(
453
-            'url'    => self::$apiUrlAsset,
454
-            'method' => 'GET',
455
-            'query'  => array(
456
-            	'api_key' => Route4Me::getApiKey(),
457
-                'tracking' => isset($params['tracking']) ? $params['tracking'] : null
458
-                )
459
-        ));
460
-
461
-        return $route;
453
+			'url'    => self::$apiUrlAsset,
454
+			'method' => 'GET',
455
+			'query'  => array(
456
+				'api_key' => Route4Me::getApiKey(),
457
+				'tracking' => isset($params['tracking']) ? $params['tracking'] : null
458
+				)
459
+		));
460
+
461
+		return $route;
462 462
 		
463 463
 	}
464 464
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 {
14 14
     static public $apiUrl = '/api.v4/route.php';
15 15
 	static public $apiUrlAddress = '/api.v4/address.php';
16
-	static public $apiUrlDuplicate='/actions/duplicate_route.php';
17
-	static public $apiUrlDelete='/actions/delete_routes.php';
18
-	static public $apiUrlReseq='/api.v3/route/reoptimize_2.php';
19
-	static public $apiUrlMerge='/actions/merge_routes.php';
20
-	static public $apiUrlShare='/actions/route/share_route.php';
21
-	static public $apiUrlNoteFile='/actions/addRouteNotes.php';
22
-	static public $apiUrlAsset='/api.v4/status.php';
23
-	static public $apiUrlDeviceLocation='/api/track/get_device_location.php';
16
+	static public $apiUrlDuplicate = '/actions/duplicate_route.php';
17
+	static public $apiUrlDelete = '/actions/delete_routes.php';
18
+	static public $apiUrlReseq = '/api.v3/route/reoptimize_2.php';
19
+	static public $apiUrlMerge = '/actions/merge_routes.php';
20
+	static public $apiUrlShare = '/actions/route/share_route.php';
21
+	static public $apiUrlNoteFile = '/actions/addRouteNotes.php';
22
+	static public $apiUrlAsset = '/api.v4/status.php';
23
+	static public $apiUrlDeviceLocation = '/api/track/get_device_location.php';
24 24
 	//static public $apiUrlMove='/actions/route/move_route_destination.php';
25 25
     public $route_id;
26 26
 	public $route_destination_id;
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
         return $route;
80 80
     }
81 81
 
82
-    public static function getRoutes($routeId=null, $params=null)
82
+    public static function getRoutes($routeId = null, $params = null)
83 83
     {
84 84
         $query = array(
85 85
             'api_key' => Route4Me::getApiKey()
86 86
         );
87 87
 
88 88
         if ($routeId) {
89
-            $query['route_id'] = implode(',', (array) $routeId);
89
+            $query['route_id'] = implode(',', (array)$routeId);
90 90
         }
91 91
 
92 92
         if ($params) {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             return Route::fromArray($json); die("");
121 121
         } else {
122 122
             $routes = array();
123
-            foreach($json as $route) {
123
+            foreach ($json as $route) {
124 124
                 $routes[] = Route::fromArray($route);
125 125
             }
126 126
             return $routes;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	}
230 230
 	
231 231
 	// Getting random route_id from existing routes between $offset and $offset+$limit
232
-	public function getRandomRouteId($offset,$limit)
232
+	public function getRandomRouteId($offset, $limit)
233 233
 	{
234 234
 		$query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
235 235
         $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
         
243 243
         if (sizeof($json)>0) {
244 244
             $routes = array();
245
-            foreach($json as $route) {
245
+            foreach ($json as $route) {
246 246
                 $routes[] = Route::fromArray($route);
247 247
             }
248 248
             
249
-            $num=rand(0,sizeof($routes)-1);
250
-            $rRoute=(array)$routes[$num];
249
+            $num = rand(0, sizeof($routes) - 1);
250
+            $rRoute = (array)$routes[$num];
251 251
             
252 252
             if (is_array($rRoute)) 
253 253
             {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                 'route_id' => isset($this->route_id) ? $this->route_id : null,
269 269
                 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
270 270
             ),
271
-            'body' => array (
271
+            'body' => array(
272 272
             	'parameters' => $this->parameters,
273 273
             	),
274 274
             'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		$fname = isset($params['strFilename']) ? $params['strFilename'] : null;
332 332
 		$rpath = realpath($fname);
333 333
 		//echo $rpath;die("");
334
-		$result= Route4Me::makeRequst(array(
334
+		$result = Route4Me::makeRequst(array(
335 335
             'url'    => self::$apiUrlNoteFile,
336 336
             'method' => 'POST',
337 337
             'query'  => array(
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
         $result = Route4Me::makeRequst(array(
364 364
             'url'    => self::$apiUrl,
365 365
             'method' => 'DELETE',
366
-            'query'  => array( 'route_id' => $route_id )
366
+            'query'  => array('route_id' => $route_id)
367 367
         ));
368 368
 		
369 369
 		// The code below doesn't work, altough this method is described as workable in REST API 
@@ -382,24 +382,24 @@  discard block
 block discarded – undo
382 382
 	
383 383
 	public function GetAddressesFromRoute($route_id)
384 384
 	{
385
-		$route1=Route::getRoutes($route_id,null);
385
+		$route1 = Route::getRoutes($route_id, null);
386 386
 		if (isset($route1)) {
387 387
 			return $route1->addresses();
388
-		} else { return null;}
388
+		} else { return null; }
389 389
 	}
390 390
 	
391 391
 	public function GetRandomAddressFromRoute($route_id)
392 392
 	{
393
-		$route1=Route::getRoutes($route_id,null);
393
+		$route1 = Route::getRoutes($route_id, null);
394 394
 		
395 395
 		if (isset($route1)) {
396
-			$addresses=$route1->addresses;
396
+			$addresses = $route1->addresses;
397 397
 			
398
-			$rnd=rand(0,sizeof($addresses)-1);
398
+			$rnd = rand(0, sizeof($addresses) - 1);
399 399
 			
400 400
 			return $addresses[$rnd];
401 401
 			
402
-		} else { return null;}
402
+		} else { return null; }
403 403
 	}
404 404
 
405 405
     public function getRouteId()
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -252,9 +252,12 @@
 block discarded – undo
252 252
             if (is_array($rRoute)) 
253 253
             {
254 254
                 return $rRoute["route_id"];
255
+            } else {
256
+            	return null;
255 257
             }
256
-            else return null;
257
-        } else return null;
258
+        } else {
259
+        	return null;
260
+        }
258 261
 		
259 262
 		
260 263
 	}
Please login to merge, or discard this patch.
src/Route4Me/Address.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,56 +9,56 @@  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 $addressUpdate;
22
-    public $is_depot = false;
23
-    public $lat;
24
-    public $lng;
25
-    public $route_id;
26
-    public $original_route_id;
27
-    public $optimization_problem_id;
28
-    public $sequence_no;
29
-    public $geocoded;
30
-    public $preferred_geocoding;
31
-    public $failed_geocoding;
32
-    public $geocodings = array();
33
-    public $contact_id;
34
-    public $is_visited;
35
-    public $customer_po;
36
-    public $invoice_no;
37
-    public $reference_no;
38
-    public $order_no;
39
-    public $weight;
40
-    public $cost;
41
-    public $revenue;
42
-    public $cube;
43
-    public $pieces;
44
-    public $email;
45
-    public $phone;
46
-    public $destination_note_count;
47
-    public $drive_time_to_next_destination;
48
-    public $distance_to_next_destination;
49
-    public $generated_time_window_start;
50
-    public $generated_time_window_end;
51
-    public $time_window_start;
52
-    public $time_window_end;
53
-    public $time;
17
+	public $route_destination_id;
18
+	public $alias;
19
+	public $member_id;
20
+	public $address;
21
+	public $addressUpdate;
22
+	public $is_depot = false;
23
+	public $lat;
24
+	public $lng;
25
+	public $route_id;
26
+	public $original_route_id;
27
+	public $optimization_problem_id;
28
+	public $sequence_no;
29
+	public $geocoded;
30
+	public $preferred_geocoding;
31
+	public $failed_geocoding;
32
+	public $geocodings = array();
33
+	public $contact_id;
34
+	public $is_visited;
35
+	public $customer_po;
36
+	public $invoice_no;
37
+	public $reference_no;
38
+	public $order_no;
39
+	public $weight;
40
+	public $cost;
41
+	public $revenue;
42
+	public $cube;
43
+	public $pieces;
44
+	public $email;
45
+	public $phone;
46
+	public $destination_note_count;
47
+	public $drive_time_to_next_destination;
48
+	public $distance_to_next_destination;
49
+	public $generated_time_window_start;
50
+	public $generated_time_window_end;
51
+	public $time_window_start;
52
+	public $time_window_end;
53
+	public $time;
54 54
 	public $notes;
55
-    public $timestamp_last_visited;
56
-    public $custom_fields = array();
57
-    public $manifest = array();
55
+	public $timestamp_last_visited;
56
+	public $custom_fields = array();
57
+	public $manifest = array();
58 58
 
59
-    public static function fromArray(array $params)
60
-    {
61
-        /*if (!isset($params['address'])) {
59
+	public static function fromArray(array $params)
60
+	{
61
+		/*if (!isset($params['address'])) {
62 62
             throw new BadParam('address must be provided');
63 63
         }
64 64
 
@@ -70,142 +70,142 @@  discard block
 block discarded – undo
70 70
             throw new BadParam('lng must be provided');
71 71
         }*/
72 72
 
73
-        $address = new Address();
74
-        foreach($params as $key => $value) {
75
-            if (property_exists($address, $key)) {
76
-                $address->{$key} = $value;
77
-            }
78
-        }
73
+		$address = new Address();
74
+		foreach($params as $key => $value) {
75
+			if (property_exists($address, $key)) {
76
+				$address->{$key} = $value;
77
+			}
78
+		}
79
+
80
+		return $address;
81
+	}
79 82
 
80
-        return $address;
81
-    }
82
-
83
-    public static function getAddress($routeId, $addressId)
84
-    {
85
-        $address = Route4Me::makeRequst(array(
86
-            'url'    => self::$apiUrl,
87
-            'method' => 'GET',
88
-            'query'  => array(
89
-                'route_id'             => $routeId,
90
-                'route_destination_id' => $addressId,
91
-            )
92
-        ));
93
-
94
-        return Address::fromArray($address);
95
-    }
83
+	public static function getAddress($routeId, $addressId)
84
+	{
85
+		$address = Route4Me::makeRequst(array(
86
+			'url'    => self::$apiUrl,
87
+			'method' => 'GET',
88
+			'query'  => array(
89
+				'route_id'             => $routeId,
90
+				'route_destination_id' => $addressId,
91
+			)
92
+		));
93
+
94
+		return Address::fromArray($address);
95
+	}
96 96
 	
97 97
 	/*Get notes from the specified route destination
98 98
      * Returns an address object with notes, if an address exists, otherwise - return null.
99 99
      */
100
-    public static function GetAddressesNotes($noteParams)
101
-    {
102
-        $address = Route4Me::makeRequst(array(
103
-            'url'    => self::$apiUrl,
104
-            'method' => 'GET',
105
-            'query'  => array(
106
-                'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id']: null, 
107
-                'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null,
108
-                'notes' => 1,
109
-            )
110
-        ));
111
-
112
-        return $address;
113
-    }
114
-
115
-    public function update()
116
-    {
117
-        $addressUpdate = Route4Me::makeRequst(array(
118
-            'url'    => self::$apiUrl,
119
-            'method' => 'PUT',
120
-            'body'   => $this->toArray(),
121
-            'query'  => array(
122
-                'route_id'             => $this->route_id,
123
-                'route_destination_id' => $this->route_destination_id,
124
-            ),
125
-        ));
126
-
127
-        return Address::fromArray($addressUpdate);
128
-    }
100
+	public static function GetAddressesNotes($noteParams)
101
+	{
102
+		$address = Route4Me::makeRequst(array(
103
+			'url'    => self::$apiUrl,
104
+			'method' => 'GET',
105
+			'query'  => array(
106
+				'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id']: null, 
107
+				'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null,
108
+				'notes' => 1,
109
+			)
110
+		));
111
+
112
+		return $address;
113
+	}
114
+
115
+	public function update()
116
+	{
117
+		$addressUpdate = Route4Me::makeRequst(array(
118
+			'url'    => self::$apiUrl,
119
+			'method' => 'PUT',
120
+			'body'   => $this->toArray(),
121
+			'query'  => array(
122
+				'route_id'             => $this->route_id,
123
+				'route_destination_id' => $this->route_destination_id,
124
+			),
125
+		));
126
+
127
+		return Address::fromArray($addressUpdate);
128
+	}
129 129
 	
130 130
 	public function markAddress($params, $body)
131
-    {
132
-        $result = Route4Me::makeRequst(array(
133
-            'url'    => self::$apiUrl,
134
-            'method' => 'PUT',
135
-            'query'  => array(
136
-                'route_id'  => isset($params['route_id']) ? $params['route_id']: null, 
137
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
138
-            ),
139
-            'body'   => $body
140
-        ));
141
-
142
-        return $result;
143
-    }
131
+	{
132
+		$result = Route4Me::makeRequst(array(
133
+			'url'    => self::$apiUrl,
134
+			'method' => 'PUT',
135
+			'query'  => array(
136
+				'route_id'  => isset($params['route_id']) ? $params['route_id']: null, 
137
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
138
+			),
139
+			'body'   => $body
140
+		));
141
+
142
+		return $result;
143
+	}
144 144
 	
145 145
 	public function markAsDeparted($params)
146 146
 	{
147 147
 		$address = Route4Me::makeRequst(array(
148
-            'url'    => self::$apiUrDeparted,
149
-            'method' => 'GET',
150
-            'query'  => array(
151
-                'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
152
-                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
153
-                'is_departed'   => isset($params['is_departed']) ? $params['is_departed']: null,
154
-                'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
155
-            ),
156
-        ));
157
-
158
-        return $address;
148
+			'url'    => self::$apiUrDeparted,
149
+			'method' => 'GET',
150
+			'query'  => array(
151
+				'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
152
+				'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
153
+				'is_departed'   => isset($params['is_departed']) ? $params['is_departed']: null,
154
+				'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
155
+			),
156
+		));
157
+
158
+		return $address;
159 159
 	}
160 160
 	
161 161
 	public function markAsVisited($params)
162 162
 	{
163 163
 		$address = Route4Me::makeRequst(array(
164
-            'url'    => self::$apiUrVisited,
165
-            'method' => 'GET',
166
-            'query'  => array(
167
-                'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
168
-                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
169
-                'is_visited'   => isset($params['is_visited']) ? $params['is_visited']: null,
170
-                'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
171
-            ),
172
-        ));
173
-
174
-        return $address;
164
+			'url'    => self::$apiUrVisited,
165
+			'method' => 'GET',
166
+			'query'  => array(
167
+				'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
168
+				'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
169
+				'is_visited'   => isset($params['is_visited']) ? $params['is_visited']: null,
170
+				'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
171
+			),
172
+		));
173
+
174
+		return $address;
175 175
 	}
176 176
 
177
-    public function delete()
178
-    {
179
-        $address = Route4Me::makeRequst(array(
180
-            'url'    => self::$apiUrl,
181
-            'method' => 'DELETE',
182
-            'query'  => array(
183
-                'route_id'             => $this->route_id,
184
-                'route_destination_id' => $this->route_destination_id,
185
-            )
186
-        ));
187
-
188
-        return (bool)$address['deleted'];
189
-    }
177
+	public function delete()
178
+	{
179
+		$address = Route4Me::makeRequst(array(
180
+			'url'    => self::$apiUrl,
181
+			'method' => 'DELETE',
182
+			'query'  => array(
183
+				'route_id'             => $this->route_id,
184
+				'route_destination_id' => $this->route_destination_id,
185
+			)
186
+		));
187
+
188
+		return (bool)$address['deleted'];
189
+	}
190 190
 	
191 191
 	public function MoveDestinationToRoute($params)
192 192
 	{
193 193
 		$result = Route4Me::makeRequst(array(
194
-            'url'    => self::$apiUrlMove,
195
-            'method' => 'POST',
196
-            'query'  => array(
197
-                'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null,
198
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
199
-                'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
200
-            )
201
-        ));
202
-
203
-        return $result;
194
+			'url'    => self::$apiUrlMove,
195
+			'method' => 'POST',
196
+			'query'  => array(
197
+				'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null,
198
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
199
+				'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
200
+			)
201
+		));
202
+
203
+		return $result;
204 204
 		
205 205
 	}
206 206
 
207
-    function getAddressId()
208
-    {
209
-        return $this->route_destination_id;
210
-    }
207
+	function getAddressId()
208
+	{
209
+		return $this->route_destination_id;
210
+	}
211 211
 }
Please login to merge, or discard this patch.