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.
Completed
Branch Editing-Fixing (c4d168)
by Igor
03:30
created
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
-    public static function getValue($array, $item, $default = null)
8
-    {
9
-        return (isset($array[$item])) ? $array[$item] : $default;
10
-    }
7
+	public static 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/AddressBookLocation.php 1 patch
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -6,549 +6,549 @@
 block discarded – undo
6 6
 
7 7
 class AddressBookLocation extends Common
8 8
 {
9
-    public $address_id;
10
-    public $address_group;
11
-    public $address_alias;
12
-    public $address_1;
13
-    public $address_2;
14
-    public $first_name;
15
-    public $last_name;
16
-    public $address_email;
17
-    public $address_phone_number;
18
-    public $address_city;
19
-    public $address_state_id;
20
-    public $address_country_id;
21
-    public $address_zip;
22
-    public $cached_lat;
23
-    public $cached_lng;
24
-    public $curbside_lat;
25
-    public $curbside_lng;
26
-    public $color;
27
-    public $address_custom_data;
28
-    public $schedule;
9
+	public $address_id;
10
+	public $address_group;
11
+	public $address_alias;
12
+	public $address_1;
13
+	public $address_2;
14
+	public $first_name;
15
+	public $last_name;
16
+	public $address_email;
17
+	public $address_phone_number;
18
+	public $address_city;
19
+	public $address_state_id;
20
+	public $address_country_id;
21
+	public $address_zip;
22
+	public $cached_lat;
23
+	public $cached_lng;
24
+	public $curbside_lat;
25
+	public $curbside_lng;
26
+	public $color;
27
+	public $address_custom_data;
28
+	public $schedule;
29 29
     
30
-    public $created_timestamp;
31
-    public $member_id;
32
-    public $schedule_blacklist;
33
-    public $in_route_count;
34
-    public $last_visited_timestamp;
35
-    public $last_routed_timestamp;
36
-    public $local_time_window_start;
37
-    public $local_time_window_end;
38
-    public $local_time_window_start_2;
39
-    public $local_time_window_end_2;
40
-    public $service_time;
41
-    public $local_timezone_string;
42
-    public $address_icon;
43
-    public $address_stop_type;
44
-    public $address_cube;
45
-    public $address_pieces;
46
-    public $address_reference_no;
47
-    public $address_revenue;
48
-    public $address_weight;
49
-    public $address_priority;
50
-    public $address_customer_po;
30
+	public $created_timestamp;
31
+	public $member_id;
32
+	public $schedule_blacklist;
33
+	public $in_route_count;
34
+	public $last_visited_timestamp;
35
+	public $last_routed_timestamp;
36
+	public $local_time_window_start;
37
+	public $local_time_window_end;
38
+	public $local_time_window_start_2;
39
+	public $local_time_window_end_2;
40
+	public $service_time;
41
+	public $local_timezone_string;
42
+	public $address_icon;
43
+	public $address_stop_type;
44
+	public $address_cube;
45
+	public $address_pieces;
46
+	public $address_reference_no;
47
+	public $address_revenue;
48
+	public $address_weight;
49
+	public $address_priority;
50
+	public $address_customer_po;
51 51
     
52
-    public static function fromArray(array $params)
53
-    {
54
-        $addressbooklocation = new AddressBookLocation();
52
+	public static function fromArray(array $params)
53
+	{
54
+		$addressbooklocation = new AddressBookLocation();
55 55
         
56
-        foreach($params as $key => $value) {
57
-            if (property_exists($addressbooklocation, $key)) {
58
-                $addressbooklocation->{$key} = $value;
59
-            }
60
-        }
56
+		foreach($params as $key => $value) {
57
+			if (property_exists($addressbooklocation, $key)) {
58
+				$addressbooklocation->{$key} = $value;
59
+			}
60
+		}
61 61
         
62
-        return $addressbooklocation;
63
-    }
62
+		return $addressbooklocation;
63
+	}
64 64
     
65
-    public static function getAddressBookLocation($addressId)
66
-    {
67
-        $ablocations = Route4Me::makeRequst(array(
68
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
69
-            'method' => 'GET',
70
-            'query'  => array(
71
-                'query' => $addressId,
72
-                'limit' => 30
73
-            )
74
-        ));
65
+	public static function getAddressBookLocation($addressId)
66
+	{
67
+		$ablocations = Route4Me::makeRequst(array(
68
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
69
+			'method' => 'GET',
70
+			'query'  => array(
71
+				'query' => $addressId,
72
+				'limit' => 30
73
+			)
74
+		));
75 75
 
76
-        return $ablocations;
77
-    }
76
+		return $ablocations;
77
+	}
78 78
     
79
-    public static function searchRoutedLocation($params)
80
-    {
81
-        $result= Route4Me::makeRequst(array(
82
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
83
-            'method' => 'GET',
84
-            'query'  => array(
85
-                'display' => isset($params['display']) ? $params['display'] : null,
86
-                'query'   => isset($params['query']) ? $params['query'] : null,
87
-                'fields'  => isset($params['fields']) ? $params['fields'] : null,
88
-                'limit'   => isset($params['limit']) ? $params['limit'] : null,
89
-                'offset'  => isset($params['offset']) ? $params['offset'] : null,
90
-            )
91
-        ));
79
+	public static function searchRoutedLocation($params)
80
+	{
81
+		$result= Route4Me::makeRequst(array(
82
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
83
+			'method' => 'GET',
84
+			'query'  => array(
85
+				'display' => isset($params['display']) ? $params['display'] : null,
86
+				'query'   => isset($params['query']) ? $params['query'] : null,
87
+				'fields'  => isset($params['fields']) ? $params['fields'] : null,
88
+				'limit'   => isset($params['limit']) ? $params['limit'] : null,
89
+				'offset'  => isset($params['offset']) ? $params['offset'] : null,
90
+			)
91
+		));
92 92
 
93
-        return $result;
94
-    }
93
+		return $result;
94
+	}
95 95
     
96
-    public static function getAddressBookLocations($params)
97
-    {
98
-        $ablocations = Route4Me::makeRequst(array(
99
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
100
-            'method' => 'GET',
101
-            'query'  => array(
102
-                'limit'  => isset($params['limit']) ? $params['limit'] : null,
103
-                'offset' => isset($params['offset']) ? $params['offset'] : null,
104
-            )
105
-        ));
96
+	public static function getAddressBookLocations($params)
97
+	{
98
+		$ablocations = Route4Me::makeRequst(array(
99
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
100
+			'method' => 'GET',
101
+			'query'  => array(
102
+				'limit'  => isset($params['limit']) ? $params['limit'] : null,
103
+				'offset' => isset($params['offset']) ? $params['offset'] : null,
104
+			)
105
+		));
106 106
 
107
-        return $ablocations;
108
-    }
107
+		return $ablocations;
108
+	}
109 109
     
110
-    public static function getAddressBookLocationsByIDs($ids)
111
-    {
112
-        $ablocations = Route4Me::makeRequst(array(
113
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
114
-            'method' => 'GET',
115
-            'query'  => array(
116
-                'address_id' => $ids
117
-            )
118
-        ));
110
+	public static function getAddressBookLocationsByIDs($ids)
111
+	{
112
+		$ablocations = Route4Me::makeRequst(array(
113
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
114
+			'method' => 'GET',
115
+			'query'  => array(
116
+				'address_id' => $ids
117
+			)
118
+		));
119 119
 
120
-        return $ablocations;
121
-    }
120
+		return $ablocations;
121
+	}
122 122
     
123
-    public static function getRandomAddressBookLocation($params)
124
-    {
125
-        $ablocations = Route4Me::makeRequst(array(
126
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
127
-            'method' => 'GET',
128
-            'query'  => array(
129
-                'limit'  => isset($params['limit']) ? $params['limit'] : 0,
130
-                'offset' => isset($params['offset']) ? $params['offset'] : 10,
131
-            )
132
-        ));
123
+	public static function getRandomAddressBookLocation($params)
124
+	{
125
+		$ablocations = Route4Me::makeRequst(array(
126
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
127
+			'method' => 'GET',
128
+			'query'  => array(
129
+				'limit'  => isset($params['limit']) ? $params['limit'] : 0,
130
+				'offset' => isset($params['offset']) ? $params['offset'] : 10,
131
+			)
132
+		));
133 133
         
134
-        if (isset($ablocations["results"])) {
135
-            $locationsSize = sizeof($ablocations["results"]);
134
+		if (isset($ablocations["results"])) {
135
+			$locationsSize = sizeof($ablocations["results"]);
136 136
             
137
-            if ($locationsSize > 0) {
138
-                $randomLocationIndex = rand(0, $locationsSize - 1);
139
-                return $ablocations["results"][$randomLocationIndex];
140
-            } 
141
-        } 
137
+			if ($locationsSize > 0) {
138
+				$randomLocationIndex = rand(0, $locationsSize - 1);
139
+				return $ablocations["results"][$randomLocationIndex];
140
+			} 
141
+		} 
142 142
 
143
-        return null;
144
-    }
143
+		return null;
144
+	}
145 145
     
146
-    public static function addAdressBookLocation($params)
147
-    {
148
-        $body = array();
149
-        $abLocations = new AddressBookLocation();
146
+	public static function addAdressBookLocation($params)
147
+	{
148
+		$body = array();
149
+		$abLocations = new AddressBookLocation();
150 150
         
151
-        foreach($params as $key => $value) {
152
-            if ($key == "address_id") continue; 
153
-            if (property_exists($abLocations, $key)) {
154
-                if (isset($params->{$key})) {
155
-                    $body[$key] = $params->{$key};
156
-                } 
157
-            }
158
-        }
151
+		foreach($params as $key => $value) {
152
+			if ($key == "address_id") continue; 
153
+			if (property_exists($abLocations, $key)) {
154
+				if (isset($params->{$key})) {
155
+					$body[$key] = $params->{$key};
156
+				} 
157
+			}
158
+		}
159 159
         
160
-        $response = Route4Me::makeRequst(array(
161
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
162
-            'method' => 'POST',
163
-            'body'   => $body
164
-        ));
160
+		$response = Route4Me::makeRequst(array(
161
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
162
+			'method' => 'POST',
163
+			'body'   => $body
164
+		));
165 165
 
166
-        return $response;
167
-    }
166
+		return $response;
167
+	}
168 168
     
169
-    public function deleteAdressBookLocation($address_ids)
170
-    {
171
-        $result = Route4Me::makeRequst(array(
172
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
173
-            'method' => 'DELETEARRAY',
174
-            'query'  => array(
175
-                'address_ids' => $address_ids
176
-            )
177
-        ));
169
+	public function deleteAdressBookLocation($address_ids)
170
+	{
171
+		$result = Route4Me::makeRequst(array(
172
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
173
+			'method' => 'DELETEARRAY',
174
+			'query'  => array(
175
+				'address_ids' => $address_ids
176
+			)
177
+		));
178 178
 
179
-        return $result;
180
-    }
179
+		return $result;
180
+	}
181 181
     
182
-    public function updateAdressBookLocation($params)
183
-    {
184
-        $body = array();
185
-        $abLocations = new AddressBookLocation();
182
+	public function updateAdressBookLocation($params)
183
+	{
184
+		$body = array();
185
+		$abLocations = new AddressBookLocation();
186 186
         
187
-        foreach($params as $key => $value) {
188
-            if (property_exists($abLocations, $key)) {
189
-                if (isset($params->{$key})) {
190
-                    $body[$key] = $params->{$key};
191
-                } 
192
-            }
193
-        }
187
+		foreach($params as $key => $value) {
188
+			if (property_exists($abLocations, $key)) {
189
+				if (isset($params->{$key})) {
190
+					$body[$key] = $params->{$key};
191
+				} 
192
+			}
193
+		}
194 194
 
195
-        $response = Route4Me::makeRequst(array(
196
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
197
-            'method' => 'PUT',
198
-            'body'   => $body,
199
-        ));
195
+		$response = Route4Me::makeRequst(array(
196
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
197
+			'method' => 'PUT',
198
+			'body'   => $body,
199
+		));
200 200
 
201
-        return $response;
202
-    }
201
+		return $response;
202
+	}
203 203
         
204
-    public static function get($params)
205
-    {
206
-        $ablocations = Route4Me::makeRequst(array(
207
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
208
-            'method' => 'ADD',
209
-            'query'  => array(
210
-                'first_name' => isset($params->first_name) ? $params->first_name : null,
211
-                'address_1'  => isset($params->address_1) ? $params->address_1 : null,
212
-                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
213
-                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
214
-            )
215
-        ));
204
+	public static function get($params)
205
+	{
206
+		$ablocations = Route4Me::makeRequst(array(
207
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
208
+			'method' => 'ADD',
209
+			'query'  => array(
210
+				'first_name' => isset($params->first_name) ? $params->first_name : null,
211
+				'address_1'  => isset($params->address_1) ? $params->address_1 : null,
212
+				'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
213
+				'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
214
+			)
215
+		));
216 216
 
217
-        return $ablocations;
218
-    }
217
+		return $ablocations;
218
+	}
219 219
     
220
-    public static function validateScheduleMode($scheduleMode)
221
-    {
222
-        $schedMmodes = array("daily","weekly","monthly","annually");
220
+	public static function validateScheduleMode($scheduleMode)
221
+	{
222
+		$schedMmodes = array("daily","weekly","monthly","annually");
223 223
         
224
-        if (in_array($scheduleMode, $schedMmodes)) 
225
-            return TRUE; 
226
-        else 
227
-            return FALSE;
228
-    }
224
+		if (in_array($scheduleMode, $schedMmodes)) 
225
+			return TRUE; 
226
+		else 
227
+			return FALSE;
228
+	}
229 229
     
230
-    public static function validateScheduleEnable($scheduleEnabled)
231
-    {
232
-        $schedEnambles = array(TRUE,FALSE);
230
+	public static function validateScheduleEnable($scheduleEnabled)
231
+	{
232
+		$schedEnambles = array(TRUE,FALSE);
233 233
         
234
-        if (in_array($scheduleEnabled, $schedEnambles))
235
-            return TRUE;
236
-        else
237
-            return FALSE;
238
-    }
234
+		if (in_array($scheduleEnabled, $schedEnambles))
235
+			return TRUE;
236
+		else
237
+			return FALSE;
238
+	}
239 239
     
240
-    public static function validateScheduleEvery($scheduleEvery)
241
-    {
242
-        if (is_numeric($scheduleEvery))
243
-            return TRUE;
244
-        else
245
-            return FALSE;
246
-    }
240
+	public static function validateScheduleEvery($scheduleEvery)
241
+	{
242
+		if (is_numeric($scheduleEvery))
243
+			return TRUE;
244
+		else
245
+			return FALSE;
246
+	}
247 247
     
248
-    public static function validateScheduleWeekDays($scheduleWeekDays)
249
-    {
250
-        $weekdays = explode(',', $scheduleWeekDays);
248
+	public static function validateScheduleWeekDays($scheduleWeekDays)
249
+	{
250
+		$weekdays = explode(',', $scheduleWeekDays);
251 251
         
252
-        if (sizeof($weekdays) < 1) return FALSE;
252
+		if (sizeof($weekdays) < 1) return FALSE;
253 253
         
254
-        $isValid = TRUE;
254
+		$isValid = TRUE;
255 255
         
256
-        for ($i=0; $i < sizeof($weekdays); $i++) { 
257
-            if (is_numeric($weekdays[$i])) {
258
-                $wday = intval($weekdays[$i]);
259
-                if ($wday < 1 || $wday > 7) $isValid = FALSE;
260
-            }
261
-            else $isValid = FALSE;
262
-        }
256
+		for ($i=0; $i < sizeof($weekdays); $i++) { 
257
+			if (is_numeric($weekdays[$i])) {
258
+				$wday = intval($weekdays[$i]);
259
+				if ($wday < 1 || $wday > 7) $isValid = FALSE;
260
+			}
261
+			else $isValid = FALSE;
262
+		}
263 263
         
264
-        return $isValid;
265
-    }
264
+		return $isValid;
265
+	}
266 266
     
267
-    public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
268
-    {
269
-        $schedMonthlyMmodes = array("dates","nth");
267
+	public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
268
+	{
269
+		$schedMonthlyMmodes = array("dates","nth");
270 270
         
271
-        if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes))
272
-            return TRUE;
273
-        else
274
-            return FALSE;
275
-    }
271
+		if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes))
272
+			return TRUE;
273
+		else
274
+			return FALSE;
275
+	}
276 276
     
277
-    public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
278
-    {
279
-        $monthlyDates = explode(',', $scheduleMonthlyDates);
277
+	public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
278
+	{
279
+		$monthlyDates = explode(',', $scheduleMonthlyDates);
280 280
         
281
-        if (sizeof($monthlyDates) <1) return FALSE;
281
+		if (sizeof($monthlyDates) <1) return FALSE;
282 282
         
283
-        $isValid = TRUE;
283
+		$isValid = TRUE;
284 284
         
285
-        for ($i=0; $i < sizeof($monthlyDates); $i++) { 
286
-            if (is_numeric($monthlyDates[$i])) {
287
-                $mday = intval($monthlyDates[$i]);
288
-                if ($mday <1 || $mday > 31) $isValid = FALSE;
289
-            }
290
-            else $isValid = FALSE;
291
-        }
285
+		for ($i=0; $i < sizeof($monthlyDates); $i++) { 
286
+			if (is_numeric($monthlyDates[$i])) {
287
+				$mday = intval($monthlyDates[$i]);
288
+				if ($mday <1 || $mday > 31) $isValid = FALSE;
289
+			}
290
+			else $isValid = FALSE;
291
+		}
292 292
 
293
-        return $isValid;
294
-    }
293
+		return $isValid;
294
+	}
295 295
     
296
-    public static function validateScheduleNthN($scheduleNthN)
297
-    {
298
-        if (!is_numeric($scheduleNthN)) return FALSE;
296
+	public static function validateScheduleNthN($scheduleNthN)
297
+	{
298
+		if (!is_numeric($scheduleNthN)) return FALSE;
299 299
         
300
-        $schedNthNs = array(1,2,3,4,5,-1);
300
+		$schedNthNs = array(1,2,3,4,5,-1);
301 301
         
302
-        if (in_array($scheduleNthN, $schedNthNs))
303
-            return TRUE;
304
-        else
305
-            return FALSE;
306
-    }
302
+		if (in_array($scheduleNthN, $schedNthNs))
303
+			return TRUE;
304
+		else
305
+			return FALSE;
306
+	}
307 307
     
308
-    public static function validateScheduleNthWhat($scheduleNthWhat)
309
-    {
310
-        if (!is_numeric($scheduleNthWhat)) return FALSE;
308
+	public static function validateScheduleNthWhat($scheduleNthWhat)
309
+	{
310
+		if (!is_numeric($scheduleNthWhat)) return FALSE;
311 311
         
312
-        $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
312
+		$schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
313 313
         
314
-        if (in_array($scheduleNthWhat, $schedNthWhats))
315
-            return TRUE;
316
-        else
317
-            return FALSE;
318
-    }
314
+		if (in_array($scheduleNthWhat, $schedNthWhats))
315
+			return TRUE;
316
+		else
317
+			return FALSE;
318
+	}
319 319
     
320
-    /* Function adds the locations (with/without schedule) from the CSV file. 
320
+	/* Function adds the locations (with/without schedule) from the CSV file. 
321 321
      * $csvFileHandle - a file handler.
322 322
      * Returns array $results which contains two arrays: fail and succes.
323 323
      */
324
-    public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
325
-    {
326
-        $max_line_length = 512;
327
-        $delemietr = ',';
324
+	public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
325
+	{
326
+		$max_line_length = 512;
327
+		$delemietr = ',';
328 328
         
329
-        $results = array();
330
-        $results['fail'] = array();
331
-        $results['success'] = array();
329
+		$results = array();
330
+		$results['fail'] = array();
331
+		$results['success'] = array();
332 332
         
333
-        $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
333
+		$columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
334 334
 
335
-        if (empty($columns)) {
336
-            array_push($results['fail'],'Empty CSV table');
337
-            return ($results);
338
-        }
335
+		if (empty($columns)) {
336
+			array_push($results['fail'],'Empty CSV table');
337
+			return ($results);
338
+		}
339 339
 
340
-        $iRow = 1;
340
+		$iRow = 1;
341 341
         
342
-        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
343
-            if ($rows[$locationsFieldsMapping['cached_lat']] 
344
-                  && $rows[$locationsFieldsMapping['cached_lng']] 
345
-                  && $rows[$locationsFieldsMapping['address_1']] 
346
-                  && array(null) !== $rows) {
347
-                $curSchedule = "";
348
-                $mode = "";
342
+		while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
343
+			if ($rows[$locationsFieldsMapping['cached_lat']] 
344
+				  && $rows[$locationsFieldsMapping['cached_lng']] 
345
+				  && $rows[$locationsFieldsMapping['address_1']] 
346
+				  && array(null) !== $rows) {
347
+				$curSchedule = "";
348
+				$mode = "";
349 349
                 
350
-                if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
351
-                    if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
352
-                        $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
353
-                        $mode = $rows[$locationsFieldsMapping['schedule_mode']];
354
-                    } else {
355
-                        array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); 
356
-                        $curSchedule = "";
357
-                    }
358
-                } else {
359
-                    array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); 
360
-                    $curSchedule = "";
361
-                }
350
+				if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
351
+					if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
352
+						$curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
353
+						$mode = $rows[$locationsFieldsMapping['schedule_mode']];
354
+					} else {
355
+						array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); 
356
+						$curSchedule = "";
357
+					}
358
+				} else {
359
+					array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); 
360
+					$curSchedule = "";
361
+				}
362 362
                 
363
-                if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
364
-                    if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
365
-                        $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
366
-                    } else {
367
-                        array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  
368
-                        $curSchedule = "";
369
-                    }
370
-                }
363
+				if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
364
+					if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
365
+						$curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
366
+					} else {
367
+						array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  
368
+						$curSchedule = "";
369
+					}
370
+				}
371 371
                 
372
-                if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
373
-                    if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
374
-                        $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
375
-                        if ($mode == 'daily') {
376
-                            $curSchedule = trim($curSchedule,',');
377
-                            $curSchedule.='}';
378
-                        }
379
-                    } else {
380
-                        array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); 
381
-                        $curSchedule = ""; 
382
-                    }
383
-                }
372
+				if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
373
+					if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
374
+						$curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
375
+						if ($mode == 'daily') {
376
+							$curSchedule = trim($curSchedule,',');
377
+							$curSchedule.='}';
378
+						}
379
+					} else {
380
+						array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); 
381
+						$curSchedule = ""; 
382
+					}
383
+				}
384 384
                 
385
-                if ($mode!='daily') {
386
-                    switch ($mode) {
387
-                        case 'weekly':
388
-                            if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
389
-                                if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
390
-                                     $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
391
-                                } else {
392
-                                    array_push($results['fail'],"$iRow --> Wrong weekdays"); 
393
-                                    $curSchedule = "";
394
-                                }
395
-                            } else {
396
-                                array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); 
397
-                                $curSchedule = "";
398
-                            }
399
-                            break;
400
-                        case 'monthly':
401
-                            $monthlyMode = "";
402
-                            if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
403
-                                if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
404
-                                     $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
405
-                                     $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
406
-                                } else {
407
-                                    array_push($results['fail'],"$iRow --> Wrong monthly mode"); 
408
-                                    $curSchedule = "";
409
-                                }
410
-                            } else {
411
-                                array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); 
412
-                                $curSchedule = "";
413
-                            }
385
+				if ($mode!='daily') {
386
+					switch ($mode) {
387
+						case 'weekly':
388
+							if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
389
+								if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
390
+									 $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
391
+								} else {
392
+									array_push($results['fail'],"$iRow --> Wrong weekdays"); 
393
+									$curSchedule = "";
394
+								}
395
+							} else {
396
+								array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); 
397
+								$curSchedule = "";
398
+							}
399
+							break;
400
+						case 'monthly':
401
+							$monthlyMode = "";
402
+							if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
403
+								if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
404
+									 $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
405
+									 $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
406
+								} else {
407
+									array_push($results['fail'],"$iRow --> Wrong monthly mode"); 
408
+									$curSchedule = "";
409
+								}
410
+							} else {
411
+								array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); 
412
+								$curSchedule = "";
413
+							}
414 414
                             
415
-                            if ($monthlyMode != "") {
416
-                                switch ($monthlyMode) {
417
-                                    case 'dates':
418
-                                        if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
419
-                                            if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
420
-                                                 $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
421
-                                            } else {
422
-                                                array_push($results['fail'],"$iRow --> Wrong monthly dates"); 
423
-                                                $curSchedule = "";
424
-                                            }
425
-                                        }
426
-                                        break;
427
-                                    case 'nth':
428
-                                        if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
429
-                                            if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
430
-                                                 $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
431
-                                            } else {
432
-                                                array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); 
433
-                                                $curSchedule = "";
434
-                                            }
435
-                                        } else {
436
-                                            array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); 
437
-                                            $curSchedule = "";
438
-                                        }
415
+							if ($monthlyMode != "") {
416
+								switch ($monthlyMode) {
417
+									case 'dates':
418
+										if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
419
+											if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
420
+												 $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
421
+											} else {
422
+												array_push($results['fail'],"$iRow --> Wrong monthly dates"); 
423
+												$curSchedule = "";
424
+											}
425
+										}
426
+										break;
427
+									case 'nth':
428
+										if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
429
+											if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
430
+												 $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
431
+											} else {
432
+												array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); 
433
+												$curSchedule = "";
434
+											}
435
+										} else {
436
+											array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); 
437
+											$curSchedule = "";
438
+										}
439 439
                                         
440
-                                        if ($curSchedule != "") {
441
-                                            if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
442
-                                                if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
443
-                                                     $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
444
-                                                } else {
445
-                                                    array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); 
446
-                                                    $curSchedule = "";
447
-                                                }
448
-                                            } else {
449
-                                                array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); 
450
-                                                $curSchedule = "";
451
-                                            }
452
-                                        }
453
-                                        break;
454
-                                }
455
-                            }
456
-                            break;
457
-                        default:
458
-                            $curSchedule = "";
459
-                            break;
460
-                    }
461
-                }
440
+										if ($curSchedule != "") {
441
+											if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
442
+												if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
443
+													 $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
444
+												} else {
445
+													array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); 
446
+													$curSchedule = "";
447
+												}
448
+											} else {
449
+												array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); 
450
+												$curSchedule = "";
451
+											}
452
+										}
453
+										break;
454
+								}
455
+							}
456
+							break;
457
+						default:
458
+							$curSchedule = "";
459
+							break;
460
+					}
461
+				}
462 462
 
463
-                if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
464
-                    $iRow++; 
465
-                    continue;
466
-                }
463
+				if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
464
+					$iRow++; 
465
+					continue;
466
+				}
467 467
                 
468
-                $curSchedule =strtolower($curSchedule);
468
+				$curSchedule =strtolower($curSchedule);
469 469
                 
470
-                $curSchedule = '[{'.$curSchedule.'}]';
470
+				$curSchedule = '[{'.$curSchedule.'}]';
471 471
 
472
-                $oSchedule = json_decode($curSchedule,TRUE);
472
+				$oSchedule = json_decode($curSchedule,TRUE);
473 473
                 
474
-                $AdressBookLocationParameters = AddressBookLocation::fromArray(array(
475
-                    "cached_lat"                 => $rows[$locationsFieldsMapping['cached_lat']],
476
-                    "cached_lng"                 => $rows[$locationsFieldsMapping['cached_lng']],
477
-                    "curbside_lat"               => isset($locationsFieldsMapping['curbside_lat'])
478
-                                                     ? $rows[$locationsFieldsMapping['curbside_lat']] : null,
479
-                    "curbside_lng"               => isset($locationsFieldsMapping['curbside_lng'])
480
-                                                     ? $rows[$locationsFieldsMapping['curbside_lng']] : null,
481
-                    "address_alias"              => isset($locationsFieldsMapping['address_alias'])
482
-                                                     ? $rows[$locationsFieldsMapping['address_alias']] : null,
483
-                    "address_1"                  => $rows[$locationsFieldsMapping['address_1']],
484
-                    "address_2"                  => isset($locationsFieldsMapping['address_2'])
485
-                                                     ? $rows[$locationsFieldsMapping['address_2']] : null,
486
-                    "address_city"               => isset($locationsFieldsMapping['address_city'])
487
-                                                      ? $rows[$locationsFieldsMapping['address_city']] : null,
488
-                    "address_state_id"           => isset($locationsFieldsMapping['address_state_id'])
489
-                                                      ? $rows[$locationsFieldsMapping['address_state_id']] : null,
490
-                    "address_zip"                => isset($locationsFieldsMapping['address_zip'])
491
-                                                      ? $rows[$locationsFieldsMapping['address_zip']] : null,
492
-                    "address_phone_number"       => isset($locationsFieldsMapping['address_phone_number'])
493
-                                                      ? $rows[$locationsFieldsMapping['address_phone_number']] : null,
494
-                    "schedule"                   => isset($oSchedule) ? $oSchedule : null,
495
-                    "address_group"              => isset($locationsFieldsMapping['address_group']) 
496
-                                                      ? $rows[$locationsFieldsMapping['address_group']] : null,
497
-                    "first_name"                 => isset($locationsFieldsMapping['first_name']) 
498
-                                                      ? $rows[$locationsFieldsMapping['first_name']] : null,
499
-                    "last_name"                  => isset($locationsFieldsMapping['last_name']) 
500
-                                                      ? $rows[$locationsFieldsMapping['last_name']] : null,
501
-                    "local_time_window_start"    => isset($locationsFieldsMapping['local_time_window_start'])
502
-                                                      ? $rows[$locationsFieldsMapping['local_time_window_start']] : null,
503
-                    "local_time_window_end"      => isset($locationsFieldsMapping['local_time_window_end'])
504
-                                                      ? $rows[$locationsFieldsMapping['local_time_window_end']] : null,
505
-                    "local_time_window_start_2"  => isset($locationsFieldsMapping['local_time_window_start_2'])
506
-                                                      ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null,
507
-                    "local_time_window_end_2"    => isset($locationsFieldsMapping['local_time_window_end_2'])
508
-                                                      ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null,
509
-                    "address_email"              => isset($locationsFieldsMapping['address_email'])
510
-                                                      ? $rows[$locationsFieldsMapping['address_email']] : null,
511
-                    "address_country_id"         => isset($locationsFieldsMapping['address_country_id'])
512
-                                                      ? $rows[$locationsFieldsMapping['address_country_id']] : null,
513
-                    "address_custom_data"        => isset($locationsFieldsMapping['address_custom_data'])
514
-                                                      ? $rows[$locationsFieldsMapping['address_custom_data']] : null,
515
-                    "schedule_blacklist"         => isset($locationsFieldsMapping['schedule_blacklist'])
516
-                                                      ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null,
517
-                    "service_time"               => isset($locationsFieldsMapping['service_time'])
518
-                                                      ? $rows[$locationsFieldsMapping['service_time']] : null,
519
-                    "local_timezone_string"      => isset($locationsFieldsMapping['local_timezone_string'])
520
-                                                      ? $rows[$locationsFieldsMapping['local_timezone_string']] : null,
521
-                    "color"                      => isset($locationsFieldsMapping['color'])
522
-                                                      ? $rows[$locationsFieldsMapping['color']] : null,
523
-                    "address_icon"               => isset($locationsFieldsMapping['address_icon'])
524
-                                                      ? $rows[$locationsFieldsMapping['address_icon']] : null,
525
-                    "address_stop_type"          => isset($locationsFieldsMapping['address_stop_type'])
526
-                                                      ? $rows[$locationsFieldsMapping['address_stop_type']] : null,
527
-                    "address_cube"               => isset($locationsFieldsMapping['address_cube'])
528
-                                                      ? $rows[$locationsFieldsMapping['address_cube']] : null,
529
-                    "address_pieces"             => isset($locationsFieldsMapping['address_pieces'])
530
-                                                      ? $rows[$locationsFieldsMapping['address_pieces']] : null,
531
-                    "address_reference_no"       => isset($locationsFieldsMapping['address_reference_no'])
532
-                                                      ? $rows[$locationsFieldsMapping['address_reference_no']] : null,
533
-                    "address_revenue"            => isset($locationsFieldsMapping['address_revenue'])
534
-                                                      ? $rows[$locationsFieldsMapping['address_revenue']] : null,
535
-                    "address_weight"             => isset($locationsFieldsMapping['address_weight'])
536
-                                                      ? $rows[$locationsFieldsMapping['address_weight']] : null,
537
-                    "address_priority"           => isset($locationsFieldsMapping['address_priority'])
538
-                                                      ? $rows[$locationsFieldsMapping['address_priority']] : null,
539
-                    "address_customer_po"        => isset($locationsFieldsMapping['address_customer_po'])
540
-                                                      ? $rows[$locationsFieldsMapping['address_customer_po']] : null,
541
-                ));
474
+				$AdressBookLocationParameters = AddressBookLocation::fromArray(array(
475
+					"cached_lat"                 => $rows[$locationsFieldsMapping['cached_lat']],
476
+					"cached_lng"                 => $rows[$locationsFieldsMapping['cached_lng']],
477
+					"curbside_lat"               => isset($locationsFieldsMapping['curbside_lat'])
478
+													 ? $rows[$locationsFieldsMapping['curbside_lat']] : null,
479
+					"curbside_lng"               => isset($locationsFieldsMapping['curbside_lng'])
480
+													 ? $rows[$locationsFieldsMapping['curbside_lng']] : null,
481
+					"address_alias"              => isset($locationsFieldsMapping['address_alias'])
482
+													 ? $rows[$locationsFieldsMapping['address_alias']] : null,
483
+					"address_1"                  => $rows[$locationsFieldsMapping['address_1']],
484
+					"address_2"                  => isset($locationsFieldsMapping['address_2'])
485
+													 ? $rows[$locationsFieldsMapping['address_2']] : null,
486
+					"address_city"               => isset($locationsFieldsMapping['address_city'])
487
+													  ? $rows[$locationsFieldsMapping['address_city']] : null,
488
+					"address_state_id"           => isset($locationsFieldsMapping['address_state_id'])
489
+													  ? $rows[$locationsFieldsMapping['address_state_id']] : null,
490
+					"address_zip"                => isset($locationsFieldsMapping['address_zip'])
491
+													  ? $rows[$locationsFieldsMapping['address_zip']] : null,
492
+					"address_phone_number"       => isset($locationsFieldsMapping['address_phone_number'])
493
+													  ? $rows[$locationsFieldsMapping['address_phone_number']] : null,
494
+					"schedule"                   => isset($oSchedule) ? $oSchedule : null,
495
+					"address_group"              => isset($locationsFieldsMapping['address_group']) 
496
+													  ? $rows[$locationsFieldsMapping['address_group']] : null,
497
+					"first_name"                 => isset($locationsFieldsMapping['first_name']) 
498
+													  ? $rows[$locationsFieldsMapping['first_name']] : null,
499
+					"last_name"                  => isset($locationsFieldsMapping['last_name']) 
500
+													  ? $rows[$locationsFieldsMapping['last_name']] : null,
501
+					"local_time_window_start"    => isset($locationsFieldsMapping['local_time_window_start'])
502
+													  ? $rows[$locationsFieldsMapping['local_time_window_start']] : null,
503
+					"local_time_window_end"      => isset($locationsFieldsMapping['local_time_window_end'])
504
+													  ? $rows[$locationsFieldsMapping['local_time_window_end']] : null,
505
+					"local_time_window_start_2"  => isset($locationsFieldsMapping['local_time_window_start_2'])
506
+													  ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null,
507
+					"local_time_window_end_2"    => isset($locationsFieldsMapping['local_time_window_end_2'])
508
+													  ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null,
509
+					"address_email"              => isset($locationsFieldsMapping['address_email'])
510
+													  ? $rows[$locationsFieldsMapping['address_email']] : null,
511
+					"address_country_id"         => isset($locationsFieldsMapping['address_country_id'])
512
+													  ? $rows[$locationsFieldsMapping['address_country_id']] : null,
513
+					"address_custom_data"        => isset($locationsFieldsMapping['address_custom_data'])
514
+													  ? $rows[$locationsFieldsMapping['address_custom_data']] : null,
515
+					"schedule_blacklist"         => isset($locationsFieldsMapping['schedule_blacklist'])
516
+													  ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null,
517
+					"service_time"               => isset($locationsFieldsMapping['service_time'])
518
+													  ? $rows[$locationsFieldsMapping['service_time']] : null,
519
+					"local_timezone_string"      => isset($locationsFieldsMapping['local_timezone_string'])
520
+													  ? $rows[$locationsFieldsMapping['local_timezone_string']] : null,
521
+					"color"                      => isset($locationsFieldsMapping['color'])
522
+													  ? $rows[$locationsFieldsMapping['color']] : null,
523
+					"address_icon"               => isset($locationsFieldsMapping['address_icon'])
524
+													  ? $rows[$locationsFieldsMapping['address_icon']] : null,
525
+					"address_stop_type"          => isset($locationsFieldsMapping['address_stop_type'])
526
+													  ? $rows[$locationsFieldsMapping['address_stop_type']] : null,
527
+					"address_cube"               => isset($locationsFieldsMapping['address_cube'])
528
+													  ? $rows[$locationsFieldsMapping['address_cube']] : null,
529
+					"address_pieces"             => isset($locationsFieldsMapping['address_pieces'])
530
+													  ? $rows[$locationsFieldsMapping['address_pieces']] : null,
531
+					"address_reference_no"       => isset($locationsFieldsMapping['address_reference_no'])
532
+													  ? $rows[$locationsFieldsMapping['address_reference_no']] : null,
533
+					"address_revenue"            => isset($locationsFieldsMapping['address_revenue'])
534
+													  ? $rows[$locationsFieldsMapping['address_revenue']] : null,
535
+					"address_weight"             => isset($locationsFieldsMapping['address_weight'])
536
+													  ? $rows[$locationsFieldsMapping['address_weight']] : null,
537
+					"address_priority"           => isset($locationsFieldsMapping['address_priority'])
538
+													  ? $rows[$locationsFieldsMapping['address_priority']] : null,
539
+					"address_customer_po"        => isset($locationsFieldsMapping['address_customer_po'])
540
+													  ? $rows[$locationsFieldsMapping['address_customer_po']] : null,
541
+				));
542 542
                 
543
-                $abContacts = new AddressBookLocation();
543
+				$abContacts = new AddressBookLocation();
544 544
 
545
-                $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
545
+				$abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
546 546
                 
547
-                array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
548
-            }
549
-        }
547
+				array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
548
+			}
549
+		}
550 550
 
551
-        return $results;
552
-    }
551
+		return $results;
552
+	}
553 553
  }
554
-    
555 554
\ No newline at end of file
555
+	
556 556
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/OptimizationProblemParams.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -7,94 +7,94 @@
 block discarded – undo
7 7
 
8 8
 class OptimizationProblemParams extends Common
9 9
 {
10
-    public $optimization_problem_id;
11
-    public $reoptimize;
12
-    public $addresses = array();
13
-    public $parameters;
14
-    public $directions;
15
-    public $format;
16
-    public $route_path_output;
17
-    public $optimized_callback_url;
18
-    public $redirect = true;
10
+	public $optimization_problem_id;
11
+	public $reoptimize;
12
+	public $addresses = array();
13
+	public $parameters;
14
+	public $directions;
15
+	public $format;
16
+	public $route_path_output;
17
+	public $optimized_callback_url;
18
+	public $redirect = true;
19 19
 
20
-    public static function fromArray($params)
21
-    {
22
-        $param = new OptimizationProblemParams;
23
-        if (!isset($params['addresses'])) {
24
-            throw new BadParam('addresses must be provided.');
25
-        }
20
+	public static function fromArray($params)
21
+	{
22
+		$param = new OptimizationProblemParams;
23
+		if (!isset($params['addresses'])) {
24
+			throw new BadParam('addresses must be provided.');
25
+		}
26 26
 
27
-        if (!isset($params['parameters'])) {
28
-            throw new BadParam('parameters must be provided.');
29
-        }
27
+		if (!isset($params['parameters'])) {
28
+			throw new BadParam('parameters must be provided.');
29
+		}
30 30
 
31
-        if ($params['parameters'] instanceof RouteParameters) {
32
-            $param->setParameters($params['parameters']);
33
-        } else {
34
-            $param->setParameters(RouteParameters::fromArray($params['parameters']));
35
-        }
31
+		if ($params['parameters'] instanceof RouteParameters) {
32
+			$param->setParameters($params['parameters']);
33
+		} else {
34
+			$param->setParameters(RouteParameters::fromArray($params['parameters']));
35
+		}
36 36
 
37
-        foreach($params['addresses'] as $address) {
38
-            if (!($address instanceof Address)) {
39
-                $address = Address::fromArray($address);
40
-            }
37
+		foreach($params['addresses'] as $address) {
38
+			if (!($address instanceof Address)) {
39
+				$address = Address::fromArray($address);
40
+			}
41 41
             
42
-            $param->addAddress($address);
43
-        }
42
+			$param->addAddress($address);
43
+		}
44 44
 
45
-        $param->directions = self::getValue($params, 'directions');
46
-        $param->format = self::getValue($params, 'format');
47
-        $param->route_path_output = self::getValue($params, 'route_path_output');
48
-        $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url');
49
-        $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id');
50
-        $param->reoptimize = self::getValue($params, 'reoptimize');
51
-        $param->redirect = filter_var(
52
-            self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN);
45
+		$param->directions = self::getValue($params, 'directions');
46
+		$param->format = self::getValue($params, 'format');
47
+		$param->route_path_output = self::getValue($params, 'route_path_output');
48
+		$param->optimized_callback_url = self::getValue($params, 'optimized_callback_url');
49
+		$param->optimization_problem_id = self::getValue($params, 'optimization_problem_id');
50
+		$param->reoptimize = self::getValue($params, 'reoptimize');
51
+		$param->redirect = filter_var(
52
+			self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN);
53 53
 
54
-        return $param;
55
-    }
54
+		return $param;
55
+	}
56 56
 
57
-    public function __construct()
58
-    {
59
-        $this->parameters = new RouteParameters;
60
-    }
57
+	public function __construct()
58
+	{
59
+		$this->parameters = new RouteParameters;
60
+	}
61 61
 
62
-    public function setParameters(RouteParameters $params)
63
-    {
64
-        $this->parameters = $params;
62
+	public function setParameters(RouteParameters $params)
63
+	{
64
+		$this->parameters = $params;
65 65
         
66
-        return $this;
67
-    }
66
+		return $this;
67
+	}
68 68
 
69
-    public function addAddress(Address $address)
70
-    {
71
-        $this->addresses[] = $address;
69
+	public function addAddress(Address $address)
70
+	{
71
+		$this->addresses[] = $address;
72 72
         
73
-        return $this;
74
-    }
73
+		return $this;
74
+	}
75 75
     
76
-    public function getAddressesArray()
77
-    {
78
-        $addresses = array();
76
+	public function getAddressesArray()
77
+	{
78
+		$addresses = array();
79 79
         
80
-        foreach($this->addresses as $address) {
81
-            $addresses[] = $address->toArray();
82
-        }
80
+		foreach($this->addresses as $address) {
81
+			$addresses[] = $address->toArray();
82
+		}
83 83
         
84
-        return $addresses;
85
-    }
84
+		return $addresses;
85
+	}
86 86
 
87
-    public function getParametersArray()
88
-    {
89
-        return $this->parameters->toArray();
90
-    }
87
+	public function getParametersArray()
88
+	{
89
+		return $this->parameters->toArray();
90
+	}
91 91
 
92
-    public function setAddresses(array $addresses)
93
-    {
94
-        foreach ($addresses as $address) {
95
-            $this->addAddress($address);
96
-        }
92
+	public function setAddresses(array $addresses)
93
+	{
94
+		foreach ($addresses as $address) {
95
+			$this->addAddress($address);
96
+		}
97 97
         
98
-        return $this;
99
-    }
98
+		return $this;
99
+	}
100 100
 }
Please login to merge, or discard this patch.
src/Route4Me/MyQ.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -11,213 +11,213 @@
 block discarded – undo
11 11
 class MyQException extends \Exception {}
12 12
 
13 13
 class MyQ {
14
-    /** @var string|null $username contains the username used to authenticate with the MyQ API */
15
-    protected $username = null;
16
-    /** @var string|null $password contains the password used to authenticate with the MyQ API */
17
-    protected $password = null;
18
-    /** @var string|null $appId is the application ID used to register with the MyQ API */
19
-    protected $appId = 'NWknvuBd7LoFHfXmKNMBcgajXtZEgKUh4V7WNzMidrpUUluDpVYVZx+xT4PCM5Kx';
20
-    //protected $appId = 'Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB%2fi';
21
-    /** @var string|null $securityToken is the auth token returned after a successful login */
22
-    protected $securityToken = null;
23
-    /** @var string|null $userAgent is the User-Agent header value sent with each API request */
24
-    protected $userAgent = 'Chamberlain/3.4.1';
25
-    /** @var string|null $culture is the API culture code for the API */
26
-    protected $culture = 'en';
27
-    /** @var string|null $contentType is the content type used for all cURL requests */
28
-    protected $contentType = 'application/json';
29
-    /** @var array $headers contain HTTP headers for cURL requests */
30
-    protected $_headers = array();
31
-    protected $_deviceId = null;
32
-    protected $_locationName = null;
33
-    protected $_doorName = null;
34
-    protected $_loginUrl = 'https://myqexternal.myqdevice.com/api/v4/User/Validate';
35
-    protected $_getDeviceDetailUrl = 'https://myqexternal.myqdevice.com/api/v4/userdevicedetails/get?&filterOn=true';
36
-    protected $_putDeviceStateUrl = '/api/v4/DeviceAttribute/PutDeviceAttribute';
37
-    /** @var resource|null $_conn is the web connection to the MyQ API */
38
-    protected $_conn = null;
14
+	/** @var string|null $username contains the username used to authenticate with the MyQ API */
15
+	protected $username = null;
16
+	/** @var string|null $password contains the password used to authenticate with the MyQ API */
17
+	protected $password = null;
18
+	/** @var string|null $appId is the application ID used to register with the MyQ API */
19
+	protected $appId = 'NWknvuBd7LoFHfXmKNMBcgajXtZEgKUh4V7WNzMidrpUUluDpVYVZx+xT4PCM5Kx';
20
+	//protected $appId = 'Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB%2fi';
21
+	/** @var string|null $securityToken is the auth token returned after a successful login */
22
+	protected $securityToken = null;
23
+	/** @var string|null $userAgent is the User-Agent header value sent with each API request */
24
+	protected $userAgent = 'Chamberlain/3.4.1';
25
+	/** @var string|null $culture is the API culture code for the API */
26
+	protected $culture = 'en';
27
+	/** @var string|null $contentType is the content type used for all cURL requests */
28
+	protected $contentType = 'application/json';
29
+	/** @var array $headers contain HTTP headers for cURL requests */
30
+	protected $_headers = array();
31
+	protected $_deviceId = null;
32
+	protected $_locationName = null;
33
+	protected $_doorName = null;
34
+	protected $_loginUrl = 'https://myqexternal.myqdevice.com/api/v4/User/Validate';
35
+	protected $_getDeviceDetailUrl = 'https://myqexternal.myqdevice.com/api/v4/userdevicedetails/get?&filterOn=true';
36
+	protected $_putDeviceStateUrl = '/api/v4/DeviceAttribute/PutDeviceAttribute';
37
+	/** @var resource|null $_conn is the web connection to the MyQ API */
38
+	protected $_conn = null;
39 39
     
40
-    /**
41
-     * Initializes class. Optionally allows user to override variables
42
-     *
43
-     * @param array $params A associative array for overwriting class variables
44
-     *
45
-     * @return MyQ
46
-     */
47
-    public function __construct ($params = array())
48
-    {
49
-        // Overwrite class variables
50
-        foreach ($params as $k => $v) {
51
-            $this->$k = $v;
52
-        }
53
-        
54
-        // Initialize cURL request headers
55
-        if (sizeof($this->_headers) == 0) {
56
-            $this->_headers = array (
57
-                'MyQApplicationId' => $this->appId,
58
-                'Culture' => $this->culture,
59
-                'Content-Type' => $this->contentType,
60
-                'User-Agent' => $this->userAgent,
61
-            );
62
-        }
63
-        
64
-        // Initialize cURL connection
65
-        $this->_init();
66
-        
67
-        return $this;
68
-    }
40
+	/**
41
+	 * Initializes class. Optionally allows user to override variables
42
+	 *
43
+	 * @param array $params A associative array for overwriting class variables
44
+	 *
45
+	 * @return MyQ
46
+	 */
47
+	public function __construct ($params = array())
48
+	{
49
+		// Overwrite class variables
50
+		foreach ($params as $k => $v) {
51
+			$this->$k = $v;
52
+		}
53
+        
54
+		// Initialize cURL request headers
55
+		if (sizeof($this->_headers) == 0) {
56
+			$this->_headers = array (
57
+				'MyQApplicationId' => $this->appId,
58
+				'Culture' => $this->culture,
59
+				'Content-Type' => $this->contentType,
60
+				'User-Agent' => $this->userAgent,
61
+			);
62
+		}
63
+        
64
+		// Initialize cURL connection
65
+		$this->_init();
66
+        
67
+		return $this;
68
+	}
69 69
     
70
-    /**
71
-     * Perform a login request
72
-     *
73
-     * @param string|null $username Username to use when logging in
74
-     * @param string|null $password Password to use for logging in
75
-     *
76
-     * @return MyQ
77
-     */
78
-    public function login ($username = null, $password = null)
79
-    {
80
-        // Set username/password if not null
81
-        if (!is_null($username)) {
82
-            $this->username = $username;
83
-        }
84
-        
85
-        if (!is_null($password)) {
86
-            $this->password = $password;
87
-        }
88
-        
89
-        // confirm that we have a valid username/password
90
-        $error = array();
91
-        if (is_null($this->username)) {
92
-            $error[] = 'username';
93
-        }
94
-        
95
-        if (is_null($this->password)) {
96
-            $error[] = 'password';
97
-        }
98
-        
99
-        if (sizeof($error) > 0) {
100
-            throw new MyQException('Missing required auth credential: ' . implode(',', $error));
101
-        }
102
-        
103
-        $this->_login();
104
-    }
70
+	/**
71
+	 * Perform a login request
72
+	 *
73
+	 * @param string|null $username Username to use when logging in
74
+	 * @param string|null $password Password to use for logging in
75
+	 *
76
+	 * @return MyQ
77
+	 */
78
+	public function login ($username = null, $password = null)
79
+	{
80
+		// Set username/password if not null
81
+		if (!is_null($username)) {
82
+			$this->username = $username;
83
+		}
84
+        
85
+		if (!is_null($password)) {
86
+			$this->password = $password;
87
+		}
88
+        
89
+		// confirm that we have a valid username/password
90
+		$error = array();
91
+		if (is_null($this->username)) {
92
+			$error[] = 'username';
93
+		}
94
+        
95
+		if (is_null($this->password)) {
96
+			$error[] = 'password';
97
+		}
98
+        
99
+		if (sizeof($error) > 0) {
100
+			throw new MyQException('Missing required auth credential: ' . implode(',', $error));
101
+		}
102
+        
103
+		$this->_login();
104
+	}
105 105
     
106
-    public function getState()
107
-    {
108
-        $this->_getDetails();
109
-        $timeInState = time() - $this->_doorStateTime;
110
-        echo implode(',', array (
111
-            $this->_locationName,
112
-            $this->_doorName,
113
-            $this->_doorState,
114
-            (int)$timeInState,
115
-        ));
116
-    }
106
+	public function getState()
107
+	{
108
+		$this->_getDetails();
109
+		$timeInState = time() - $this->_doorStateTime;
110
+		echo implode(',', array (
111
+			$this->_locationName,
112
+			$this->_doorName,
113
+			$this->_doorState,
114
+			(int)$timeInState,
115
+		));
116
+	}
117 117
     
118
-    public function getDetails()
119
-    {
120
-        return $this->_getDetails();
121
-    }
118
+	public function getDetails()
119
+	{
120
+		return $this->_getDetails();
121
+	}
122 122
     
123
-    private function _init()
124
-    {
125
-        if (!isset($this->_conn)) {
126
-            $this->_conn = curl_init();
123
+	private function _init()
124
+	{
125
+		if (!isset($this->_conn)) {
126
+			$this->_conn = curl_init();
127 127
             
128
-            curl_setopt_array($this->_conn, array (
129
-                CURLOPT_RETURNTRANSFER => true,
130
-                CURLOPT_ENCODING       => "",
131
-                CURLOPT_MAXREDIRS      => 10,
132
-                CURLOPT_TIMEOUT        => 30,
133
-                CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
134
-                CURLOPT_FAILONERROR    => true,
135
-                CURLOPT_FOLLOWLOCATION => true,
136
-                CURLOPT_FRESH_CONNECT  => true,
137
-                CURLOPT_FORBID_REUSE   => true,
138
-                CURLOPT_USERAGENT      => $this->userAgent,
139
-            ));
140
-        }
141
-        
142
-        $this->_setHeaders();
143
-    }
144
-    private function _setHeaders()
145
-    {
146
-        $headers = array();
147
-        
148
-        foreach ($this->_headers as $k => $v) {
149
-            $headers[] = "$k: $v";
150
-        }
151
-        
152
-        curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers);
153
-    }
128
+			curl_setopt_array($this->_conn, array (
129
+				CURLOPT_RETURNTRANSFER => true,
130
+				CURLOPT_ENCODING       => "",
131
+				CURLOPT_MAXREDIRS      => 10,
132
+				CURLOPT_TIMEOUT        => 30,
133
+				CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
134
+				CURLOPT_FAILONERROR    => true,
135
+				CURLOPT_FOLLOWLOCATION => true,
136
+				CURLOPT_FRESH_CONNECT  => true,
137
+				CURLOPT_FORBID_REUSE   => true,
138
+				CURLOPT_USERAGENT      => $this->userAgent,
139
+			));
140
+		}
141
+        
142
+		$this->_setHeaders();
143
+	}
144
+	private function _setHeaders()
145
+	{
146
+		$headers = array();
147
+        
148
+		foreach ($this->_headers as $k => $v) {
149
+			$headers[] = "$k: $v";
150
+		}
151
+        
152
+		curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers);
153
+	}
154 154
     
155
-    private function _login()
156
-    {
157
-        $this->_init();
155
+	private function _login()
156
+	{
157
+		$this->_init();
158 158
         
159
-        curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST');
160
-        curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl);
159
+		curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST');
160
+		curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl);
161 161
         
162
-        $post = json_encode(array('username' => $this->username, 'password' => $this->password));
162
+		$post = json_encode(array('username' => $this->username, 'password' => $this->password));
163 163
         
164
-        curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post);
164
+		curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post);
165 165
         
166
-        $output = curl_exec($this->_conn);
166
+		$output = curl_exec($this->_conn);
167 167
         
168
-        $data = json_decode($output);
168
+		$data = json_decode($output);
169 169
         
170
-        if ($data == false || !isset($data->SecurityToken)) {
171
-            throw new MyQException("Error processing login request: $output");
172
-        }
170
+		if ($data == false || !isset($data->SecurityToken)) {
171
+			throw new MyQException("Error processing login request: $output");
172
+		}
173 173
         
174
-        $this->_headers['SecurityToken'] = $data->SecurityToken;
174
+		$this->_headers['SecurityToken'] = $data->SecurityToken;
175 175
         
176
-        return $this;
177
-    }
176
+		return $this;
177
+	}
178 178
     
179
-    private function _getDetails()
180
-    {
181
-        $this->_init();
182
-        
183
-        curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET');
184
-        curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl);
185
-        
186
-        $output = curl_exec($this->_conn);
187
-        
188
-        $data = json_decode($output);
189
-        
190
-        if ($data == false || !isset($data->Devices)) {
191
-            throw new MyQException("Error fetching device details: $output");
192
-        }
193
-        
194
-        // Find our door device ID
195
-        foreach ($data->Devices as $device) {
196
-            if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) {
197
-                // Find location name
198
-                foreach ($device->Attributes as $attr) {
199
-                    if ($attr->AttributeDisplayName == 'desc') {
200
-                        $this->_locationName = $attr->Value;
201
-                    }
202
-                }
203
-            }
179
+	private function _getDetails()
180
+	{
181
+		$this->_init();
182
+        
183
+		curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET');
184
+		curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl);
185
+        
186
+		$output = curl_exec($this->_conn);
187
+        
188
+		$data = json_decode($output);
189
+        
190
+		if ($data == false || !isset($data->Devices)) {
191
+			throw new MyQException("Error fetching device details: $output");
192
+		}
193
+        
194
+		// Find our door device ID
195
+		foreach ($data->Devices as $device) {
196
+			if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) {
197
+				// Find location name
198
+				foreach ($device->Attributes as $attr) {
199
+					if ($attr->AttributeDisplayName == 'desc') {
200
+						$this->_locationName = $attr->Value;
201
+					}
202
+				}
203
+			}
204 204
             
205
-            $this->_deviceId = $device->MyQDeviceId;
205
+			$this->_deviceId = $device->MyQDeviceId;
206 206
             
207
-            foreach ($device->Attributes as $attr) {
208
-                switch ($attr->AttributeDisplayName) {
209
-                    case 'desc':
210
-                        $this->_doorName = $attr->Value;
211
-                        break;
212
-                    case 'doorstate':
213
-                        $this->_doorState = $attr->Value;
214
-                        // UpdatedTime is a timestamp in ms, so we truncate
215
-                        $this->_doorStateTime = (int)$attr->UpdatedTime / 1000;
216
-                        break;
217
-                    default:
218
-                        continue;
219
-                }
220
-            }
221
-        }
222
-    }
207
+			foreach ($device->Attributes as $attr) {
208
+				switch ($attr->AttributeDisplayName) {
209
+					case 'desc':
210
+						$this->_doorName = $attr->Value;
211
+						break;
212
+					case 'doorstate':
213
+						$this->_doorState = $attr->Value;
214
+						// UpdatedTime is a timestamp in ms, so we truncate
215
+						$this->_doorStateTime = (int)$attr->UpdatedTime / 1000;
216
+						break;
217
+					default:
218
+						continue;
219
+				}
220
+			}
221
+		}
222
+	}
223 223
 }
Please login to merge, or discard this patch.
src/Route4Me/Address.php 1 patch
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -9,63 +9,63 @@  discard block
 block discarded – undo
9 9
 
10 10
 class Address extends Common
11 11
 {
12
-    public $route_destination_id;
13
-    public $alias;
14
-    public $member_id;
15
-    public $address;
16
-    public $addressUpdate;
17
-    public $is_depot = false;
18
-    public $lat;
19
-    public $lng;
20
-    public $route_id;
21
-    public $original_route_id;
22
-    public $optimization_problem_id;
23
-    public $sequence_no;
24
-    public $geocoded;
25
-    public $preferred_geocoding;
26
-    public $failed_geocoding;
27
-    public $geocodings = array();
28
-    public $contact_id;
29
-    public $is_visited;
30
-    public $customer_po;
31
-    public $invoice_no;
32
-    public $reference_no;
33
-    public $order_no;
34
-    public $weight;
35
-    public $cost;
36
-    public $revenue;
37
-    public $cube;
38
-    public $pieces;
39
-    public $email;
40
-    public $phone;
41
-    public $tracking_number;
42
-    public $destination_note_count;
43
-    public $drive_time_to_next_destination;
44
-    public $distance_to_next_destination;
45
-    public $generated_time_window_start;
46
-    public $generated_time_window_end;
47
-    public $time_window_start;
48
-    public $time_window_end;
49
-    public $time;
50
-    public $notes;
51
-    public $timestamp_last_visited;
52
-    public $custom_fields = array();
53
-    public $manifest = array();
12
+	public $route_destination_id;
13
+	public $alias;
14
+	public $member_id;
15
+	public $address;
16
+	public $addressUpdate;
17
+	public $is_depot = false;
18
+	public $lat;
19
+	public $lng;
20
+	public $route_id;
21
+	public $original_route_id;
22
+	public $optimization_problem_id;
23
+	public $sequence_no;
24
+	public $geocoded;
25
+	public $preferred_geocoding;
26
+	public $failed_geocoding;
27
+	public $geocodings = array();
28
+	public $contact_id;
29
+	public $is_visited;
30
+	public $customer_po;
31
+	public $invoice_no;
32
+	public $reference_no;
33
+	public $order_no;
34
+	public $weight;
35
+	public $cost;
36
+	public $revenue;
37
+	public $cube;
38
+	public $pieces;
39
+	public $email;
40
+	public $phone;
41
+	public $tracking_number;
42
+	public $destination_note_count;
43
+	public $drive_time_to_next_destination;
44
+	public $distance_to_next_destination;
45
+	public $generated_time_window_start;
46
+	public $generated_time_window_end;
47
+	public $time_window_start;
48
+	public $time_window_end;
49
+	public $time;
50
+	public $notes;
51
+	public $timestamp_last_visited;
52
+	public $custom_fields = array();
53
+	public $manifest = array();
54 54
     
55
-    public $first_name;
56
-    public $last_name;
57
-    public $is_departed;
58
-    public $timestamp_last_departed;
59
-    public $order_id;
60
-    public $priority;
61
-    public $curbside_lat;
62
-    public $curbside_lng;
63
-    public $time_window_start_2;
64
-    public $time_window_end_2;
55
+	public $first_name;
56
+	public $last_name;
57
+	public $is_departed;
58
+	public $timestamp_last_departed;
59
+	public $order_id;
60
+	public $priority;
61
+	public $curbside_lat;
62
+	public $curbside_lng;
63
+	public $time_window_start_2;
64
+	public $time_window_end_2;
65 65
 
66
-    public static function fromArray(array $params)
67
-    {
68
-        /*if (!isset($params['address'])) {
66
+	public static function fromArray(array $params)
67
+	{
68
+		/*if (!isset($params['address'])) {
69 69
             throw new BadParam('address must be provided');
70 70
         }
71 71
 
@@ -77,260 +77,260 @@  discard block
 block discarded – undo
77 77
             throw new BadParam('lng must be provided');
78 78
         }*/
79 79
 
80
-        $address = new Address();
81
-        foreach($params as $key => $value) {
82
-            if (property_exists($address, $key)) {
83
-                $address->{$key} = $value;
84
-            }
85
-        }
80
+		$address = new Address();
81
+		foreach($params as $key => $value) {
82
+			if (property_exists($address, $key)) {
83
+				$address->{$key} = $value;
84
+			}
85
+		}
86 86
 
87
-        return $address;
88
-    }
87
+		return $address;
88
+	}
89 89
 
90
-    public static function getAddress($routeId, $addressId)
91
-    {
92
-        $address = Route4Me::makeRequst(array(
93
-            'url'    => Endpoint::ADDRESS_V4,
94
-            'method' => 'GET',
95
-            'query'  => array(
96
-                'route_id'             => $routeId,
97
-                'route_destination_id' => $addressId,
98
-            )
99
-        ));
90
+	public static function getAddress($routeId, $addressId)
91
+	{
92
+		$address = Route4Me::makeRequst(array(
93
+			'url'    => Endpoint::ADDRESS_V4,
94
+			'method' => 'GET',
95
+			'query'  => array(
96
+				'route_id'             => $routeId,
97
+				'route_destination_id' => $addressId,
98
+			)
99
+		));
100 100
 
101
-        return Address::fromArray($address);
102
-    }
101
+		return Address::fromArray($address);
102
+	}
103 103
     
104
-    /*Get notes from the specified route destination
104
+	/*Get notes from the specified route destination
105 105
      * Returns an address object with notes, if an address exists, otherwise - return null.
106 106
      */
107
-    public static function GetAddressesNotes($noteParams)
108
-    {
109
-        $address = Route4Me::makeRequst(array(
110
-            'url'    => Endpoint::ADDRESS_V4,
111
-            'method' => 'GET',
112
-            'query'  => array(
113
-                'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, 
114
-                'route_destination_id' => isset($noteParams['route_destination_id']) 
115
-                                             ? $noteParams['route_destination_id'] : null,
116
-                'notes'                => 1,
117
-            )
118
-        ));
107
+	public static function GetAddressesNotes($noteParams)
108
+	{
109
+		$address = Route4Me::makeRequst(array(
110
+			'url'    => Endpoint::ADDRESS_V4,
111
+			'method' => 'GET',
112
+			'query'  => array(
113
+				'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, 
114
+				'route_destination_id' => isset($noteParams['route_destination_id']) 
115
+											 ? $noteParams['route_destination_id'] : null,
116
+				'notes'                => 1,
117
+			)
118
+		));
119 119
 
120
-        return $address;
121
-    }
120
+		return $address;
121
+	}
122 122
 
123
-    public function update()
124
-    {
125
-        $addressUpdate = Route4Me::makeRequst(array(
126
-            'url'    => Endpoint::ADDRESS_V4,
127
-            'method' => 'PUT',
128
-            'body'   => $this->toArray(),
129
-            'query'  => array(
130
-                'route_id'             => $this->route_id,
131
-                'route_destination_id' => $this->route_destination_id,
132
-            ),
133
-        ));
123
+	public function update()
124
+	{
125
+		$addressUpdate = Route4Me::makeRequst(array(
126
+			'url'    => Endpoint::ADDRESS_V4,
127
+			'method' => 'PUT',
128
+			'body'   => $this->toArray(),
129
+			'query'  => array(
130
+				'route_id'             => $this->route_id,
131
+				'route_destination_id' => $this->route_destination_id,
132
+			),
133
+		));
134 134
 
135
-        return Address::fromArray($addressUpdate);
136
-    }
135
+		return Address::fromArray($addressUpdate);
136
+	}
137 137
     
138
-    public function markAddress($params, $body)
139
-    {
140
-        $result = Route4Me::makeRequst(array(
141
-            'url'    => Endpoint::ADDRESS_V4,
142
-            'method' => 'PUT',
143
-            'query'  => array(
144
-                'route_id'             => isset($params['route_id']) ? $params['route_id'] : null, 
145
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
146
-            ),
147
-            'body'   => $body
148
-        ));
138
+	public function markAddress($params, $body)
139
+	{
140
+		$result = Route4Me::makeRequst(array(
141
+			'url'    => Endpoint::ADDRESS_V4,
142
+			'method' => 'PUT',
143
+			'query'  => array(
144
+				'route_id'             => isset($params['route_id']) ? $params['route_id'] : null, 
145
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
146
+			),
147
+			'body'   => $body
148
+		));
149 149
 
150
-        return $result;
151
-    }
150
+		return $result;
151
+	}
152 152
     
153
-    public function markAsDeparted($params)
154
-    {
155
-        $address = Route4Me::makeRequst(array(
156
-            'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
157
-            'method' => 'GET',
158
-            'query'  => array(
159
-                'route_id'     => isset($params['route_id']) ? $params['route_id']: null,
160
-                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
161
-                'is_departed'  => isset($params['is_departed']) ? $params['is_departed']: null,
162
-                'member_id'    => isset($params['member_id']) ? $params['member_id']: null,
163
-            ),
164
-        ));
153
+	public function markAsDeparted($params)
154
+	{
155
+		$address = Route4Me::makeRequst(array(
156
+			'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
157
+			'method' => 'GET',
158
+			'query'  => array(
159
+				'route_id'     => isset($params['route_id']) ? $params['route_id']: null,
160
+				'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
161
+				'is_departed'  => isset($params['is_departed']) ? $params['is_departed']: null,
162
+				'member_id'    => isset($params['member_id']) ? $params['member_id']: null,
163
+			),
164
+		));
165 165
 
166
-        return $address;
167
-    }
166
+		return $address;
167
+	}
168 168
     
169
-    public function markAsVisited($params)
170
-    {
171
-        $address = Route4Me::makeRequst(array(
172
-            'url'    => Endpoint::UPDATE_ADDRESS_VISITED,
173
-            'method' => 'GET',
174
-            'query'  => array(
175
-                'route_id'   => isset($params['route_id']) ? $params['route_id'] : null,
176
-                'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
177
-                'member_id'  => isset($params['member_id']) ? $params['member_id'] : null,
178
-            ),
179
-            'body'  =>  array(
180
-                'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null
181
-            )
182
-        ));
169
+	public function markAsVisited($params)
170
+	{
171
+		$address = Route4Me::makeRequst(array(
172
+			'url'    => Endpoint::UPDATE_ADDRESS_VISITED,
173
+			'method' => 'GET',
174
+			'query'  => array(
175
+				'route_id'   => isset($params['route_id']) ? $params['route_id'] : null,
176
+				'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
177
+				'member_id'  => isset($params['member_id']) ? $params['member_id'] : null,
178
+			),
179
+			'body'  =>  array(
180
+				'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null
181
+			)
182
+		));
183 183
 
184
-        return $address;
185
-    }
184
+		return $address;
185
+	}
186 186
 
187
-    public function delete()
188
-    {
189
-        $address = Route4Me::makeRequst(array(
190
-            'url'    => Endpoint::ADDRESS_V4,
191
-            'method' => 'DELETE',
192
-            'query'  => array(
193
-                'route_id'             => $this->route_id,
194
-                'route_destination_id' => $this->route_destination_id,
195
-            )
196
-        ));
187
+	public function delete()
188
+	{
189
+		$address = Route4Me::makeRequst(array(
190
+			'url'    => Endpoint::ADDRESS_V4,
191
+			'method' => 'DELETE',
192
+			'query'  => array(
193
+				'route_id'             => $this->route_id,
194
+				'route_destination_id' => $this->route_destination_id,
195
+			)
196
+		));
197 197
 
198
-        return (bool)$address['deleted'];
199
-    }
198
+		return (bool)$address['deleted'];
199
+	}
200 200
     
201
-    public function moveDestinationToRoute($params)
202
-    {
203
-        $result = Route4Me::makeRequst(array(
204
-            'url'    => Endpoint::MOVE_ROUTE_DESTINATION,
205
-            'method' => 'POST',
206
-            'body'  => array(
207
-                'to_route_id'          => isset($params['to_route_id']) ? $params['to_route_id'] : null,
208
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
209
-                'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
210
-            ),
211
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
212
-        ));
201
+	public function moveDestinationToRoute($params)
202
+	{
203
+		$result = Route4Me::makeRequst(array(
204
+			'url'    => Endpoint::MOVE_ROUTE_DESTINATION,
205
+			'method' => 'POST',
206
+			'body'  => array(
207
+				'to_route_id'          => isset($params['to_route_id']) ? $params['to_route_id'] : null,
208
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
209
+				'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
210
+			),
211
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
212
+		));
213 213
 
214
-        return $result;
214
+		return $result;
215 215
         
216
-    }
216
+	}
217 217
     
218
-    public function AddAddressNote($params)
219
-    {
220
-        $result = Route4Me::makeRequst(array(
221
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
222
-            'method' => 'POST',
223
-            'query'  => array(
224
-                'route_id'     =>  isset($params['route_id']) ? $params['route_id'] : null,
225
-                'address_id'   =>  isset($params['address_id']) ? $params['address_id'] : null,
226
-                'dev_lat'      =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
227
-                'dev_lng'      =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
228
-                'device_type'  =>  isset($params['device_type']) ? $params['device_type'] : null
229
-            ),
230
-            'body'  => array(
231
-                'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
232
-                'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null
233
-            ),
234
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
235
-        ));
218
+	public function AddAddressNote($params)
219
+	{
220
+		$result = Route4Me::makeRequst(array(
221
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
222
+			'method' => 'POST',
223
+			'query'  => array(
224
+				'route_id'     =>  isset($params['route_id']) ? $params['route_id'] : null,
225
+				'address_id'   =>  isset($params['address_id']) ? $params['address_id'] : null,
226
+				'dev_lat'      =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
227
+				'dev_lng'      =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
228
+				'device_type'  =>  isset($params['device_type']) ? $params['device_type'] : null
229
+			),
230
+			'body'  => array(
231
+				'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
232
+				'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null
233
+			),
234
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
235
+		));
236 236
 
237
-        return $result;
238
-    }
237
+		return $result;
238
+	}
239 239
 
240
-    public function AddNoteFile($params)
241
-    {
242
-        $result = Route4Me::fileUploadRequest(array(
243
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
244
-            'method' => 'POST',
245
-            'query'  => array(
246
-                'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
247
-                'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
248
-                'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
249
-                'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
250
-                'device_type'   =>  isset($params['device_type']) ? $params['device_type'] : null,
251
-                'strUpdateType' =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null
252
-            ),
253
-            'body'  => array(
254
-                'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null
255
-            ),
256
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
257
-        ));
240
+	public function AddNoteFile($params)
241
+	{
242
+		$result = Route4Me::fileUploadRequest(array(
243
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
244
+			'method' => 'POST',
245
+			'query'  => array(
246
+				'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
247
+				'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
248
+				'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
249
+				'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
250
+				'device_type'   =>  isset($params['device_type']) ? $params['device_type'] : null,
251
+				'strUpdateType' =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null
252
+			),
253
+			'body'  => array(
254
+				'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null
255
+			),
256
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
257
+		));
258 258
 
259
-        return $result;
260
-    }
259
+		return $result;
260
+	}
261 261
 
262
-    public function createCustomNoteType($params)
263
-    {
264
-        $result = Route4Me::makeRequst(array(
265
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
266
-            'method' => 'POST',
267
-            'body'   => array(
268
-                'type'   => isset($params['type']) ? $params['type'] : null,
269
-                'values' => isset($params['values']) ? $params['values'] : null
270
-            )
271
-        ));
262
+	public function createCustomNoteType($params)
263
+	{
264
+		$result = Route4Me::makeRequst(array(
265
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
266
+			'method' => 'POST',
267
+			'body'   => array(
268
+				'type'   => isset($params['type']) ? $params['type'] : null,
269
+				'values' => isset($params['values']) ? $params['values'] : null
270
+			)
271
+		));
272 272
 
273
-        return $result;
274
-    }
273
+		return $result;
274
+	}
275 275
     
276
-    public function removeCustomNoteType($params)
277
-    {
278
-        $result = Route4Me::makeRequst(array(
279
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
280
-            'method' => 'DELETE',
281
-            'body'   => array(
282
-                'id' => isset($params['id']) ? $params['id'] : null
283
-            )
284
-        ));
276
+	public function removeCustomNoteType($params)
277
+	{
278
+		$result = Route4Me::makeRequst(array(
279
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
280
+			'method' => 'DELETE',
281
+			'body'   => array(
282
+				'id' => isset($params['id']) ? $params['id'] : null
283
+			)
284
+		));
285 285
 
286
-        return $result;
287
-    }
286
+		return $result;
287
+	}
288 288
     
289
-    public function getAllCustomNoteTypes()
290
-    {
291
-        $result = Route4Me::makeRequst(array(
292
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
293
-            'method' => 'GET'
294
-        ));
289
+	public function getAllCustomNoteTypes()
290
+	{
291
+		$result = Route4Me::makeRequst(array(
292
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
293
+			'method' => 'GET'
294
+		));
295 295
 
296
-        return $result;
297
-    }
296
+		return $result;
297
+	}
298 298
     
299
-    public function addCustomNoteToRoute($params)
300
-    {
301
-        $customArray = array();
299
+	public function addCustomNoteToRoute($params)
300
+	{
301
+		$customArray = array();
302 302
         
303
-        foreach ($params as $key => $value) {
304
-            $kpos = strpos($key, "custom_note_type");
303
+		foreach ($params as $key => $value) {
304
+			$kpos = strpos($key, "custom_note_type");
305 305
             
306
-            if ($kpos !== false) {
307
-                $customArray[$key]=$value;
308
-            }
309
-        }
306
+			if ($kpos !== false) {
307
+				$customArray[$key]=$value;
308
+			}
309
+		}
310 310
         
311
-        $result = Route4Me::makeRequst(array(
312
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
313
-            'method' => 'POST',
314
-            'query'  => array(
315
-                'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
316
-                'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
317
-                'format'        =>  isset($params['format']) ? $params['format'] : null,
318
-                'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
319
-                'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null
320
-            ),
321
-            'body'  => array_merge(array(
322
-                'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
323
-                'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
324
-                'strNoteContents' =>  isset($params['strNoteContents']) ? $params['strNoteContents'] : null
325
-            ), $customArray),
326
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
327
-        ));
311
+		$result = Route4Me::makeRequst(array(
312
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
313
+			'method' => 'POST',
314
+			'query'  => array(
315
+				'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
316
+				'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
317
+				'format'        =>  isset($params['format']) ? $params['format'] : null,
318
+				'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
319
+				'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null
320
+			),
321
+			'body'  => array_merge(array(
322
+				'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
323
+				'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
324
+				'strNoteContents' =>  isset($params['strNoteContents']) ? $params['strNoteContents'] : null
325
+			), $customArray),
326
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
327
+		));
328 328
 
329
-        return $result;
330
-    }
329
+		return $result;
330
+	}
331 331
 
332
-    function getAddressId()
333
-    {
334
-        return $this->route_destination_id;
335
-    }
332
+	function getAddressId()
333
+	{
334
+		return $this->route_destination_id;
335
+	}
336 336
 }
Please login to merge, or discard this patch.
src/Route4Me/Exception/myErrorHandler.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@
 block discarded – undo
3 3
 
4 4
 class myErrorHandler extends \Exception
5 5
 {
6
-    public function proc_error($errno, $errstr, $errfile, $errline) 
7
-    {
8
-        echo "line: $errline --- ".$errstr."<br>";
6
+	public function proc_error($errno, $errstr, $errfile, $errline) 
7
+	{
8
+		echo "line: $errline --- ".$errstr."<br>";
9 9
     
10
-    }
10
+	}
11 11
 }
Please login to merge, or discard this patch.
src/Route4Me/curl_http_client.php 1 patch
Indentation   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -3,373 +3,373 @@  discard block
 block discarded – undo
3 3
 
4 4
 class CurlHttpClient
5 5
 {
6
-    var $ch ;
7
-    var $debug = false;
8
-    var $error_msg;
6
+	var $ch ;
7
+	var $debug = false;
8
+	var $error_msg;
9 9
 
10
-    function CurlHttpClient($debug = false)
11
-    {
12
-        $this->debug = $debug;
13
-        $this->init();
14
-    }
10
+	function CurlHttpClient($debug = false)
11
+	{
12
+		$this->debug = $debug;
13
+		$this->init();
14
+	}
15 15
     
16
-    function init()
17
-    {
18
-        // initialize curl handle
19
-        $this->ch = curl_init();
20
-        //set various options
21
-        //set error in case http return code bigger than 300
22
-        curl_setopt($this->ch, CURLOPT_FAILONERROR, true);
23
-        // use gzip if possible
24
-        curl_setopt($this->ch,CURLOPT_ENCODING , 'gzip, deflate');
25
-        // do not veryfy ssl
26
-        // this is important for windows
27
-        // as well for being able to access pages with non valid cert
28
-        curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
29
-    }
16
+	function init()
17
+	{
18
+		// initialize curl handle
19
+		$this->ch = curl_init();
20
+		//set various options
21
+		//set error in case http return code bigger than 300
22
+		curl_setopt($this->ch, CURLOPT_FAILONERROR, true);
23
+		// use gzip if possible
24
+		curl_setopt($this->ch,CURLOPT_ENCODING , 'gzip, deflate');
25
+		// do not veryfy ssl
26
+		// this is important for windows
27
+		// as well for being able to access pages with non valid cert
28
+		curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
29
+	}
30 30
     
31
-    /**
32
-     * Set username/pass for basic http auth
33
-     * @param string user
34
-     * @param string pass
35
-     * @access public
36
-     */
37
-    function setCredentials($username,$password)
38
-    {
39
-        curl_setopt($this->ch, CURLOPT_USERPWD, "$username:$password");
40
-    }
31
+	/**
32
+	 * Set username/pass for basic http auth
33
+	 * @param string user
34
+	 * @param string pass
35
+	 * @access public
36
+	 */
37
+	function setCredentials($username,$password)
38
+	{
39
+		curl_setopt($this->ch, CURLOPT_USERPWD, "$username:$password");
40
+	}
41 41
     
42
-    /**
43
-     * Set referrer
44
-     * @param string referrer url 
45
-     * @access public
46
-     */
47
-    function setReferrer($referrer_url)
48
-    {
49
-        curl_setopt($this->ch, CURLOPT_REFERER, $referrer_url);
50
-    }
42
+	/**
43
+	 * Set referrer
44
+	 * @param string referrer url 
45
+	 * @access public
46
+	 */
47
+	function setReferrer($referrer_url)
48
+	{
49
+		curl_setopt($this->ch, CURLOPT_REFERER, $referrer_url);
50
+	}
51 51
     
52
-    /**
53
-     * Set client's userAgent
54
-     * @param string user agent
55
-     * @access public
56
-     */
57
-    function setUserAgent($userAgent)
58
-    {
59
-        curl_setopt($this->ch, CURLOPT_USERAGENT, $userAgent);
60
-    }
52
+	/**
53
+	 * Set client's userAgent
54
+	 * @param string user agent
55
+	 * @access public
56
+	 */
57
+	function setUserAgent($userAgent)
58
+	{
59
+		curl_setopt($this->ch, CURLOPT_USERAGENT, $userAgent);
60
+	}
61 61
     
62
-    /**
63
-     * Set to receive output headers in all output functions
64
-     * @param boolean true to include all response headers with output, false otherwise
65
-     * @access public
66
-     */
67
-    function includeResponseHeaders($value)
68
-    {
69
-        curl_setopt($this->ch, CURLOPT_HEADER, $value);
70
-    }
62
+	/**
63
+	 * Set to receive output headers in all output functions
64
+	 * @param boolean true to include all response headers with output, false otherwise
65
+	 * @access public
66
+	 */
67
+	function includeResponseHeaders($value)
68
+	{
69
+		curl_setopt($this->ch, CURLOPT_HEADER, $value);
70
+	}
71 71
     
72
-    /**
73
-     * Set proxy to use for each curl request
74
-     * @param string proxy
75
-     * @access public
76
-     */
77
-    function setProxy($proxy)
78
-    {
79
-        curl_setopt($this->ch, CURLOPT_PROXY, $proxy);
80
-    }
72
+	/**
73
+	 * Set proxy to use for each curl request
74
+	 * @param string proxy
75
+	 * @access public
76
+	 */
77
+	function setProxy($proxy)
78
+	{
79
+		curl_setopt($this->ch, CURLOPT_PROXY, $proxy);
80
+	}
81 81
     
82
-    /**
83
-     * Send post data to target URL     
84
-     * return data returned from url or false if error occured
85
-     * @param string url
86
-     * @param mixed post data (assoc array ie. $foo['post_var_name'] = $value or as string like var=val1&var2=val2)
87
-     * @param string ip address to bind (default null)
88
-     * @param int timeout in sec for complete curl operation (default 10)
89
-     * @return string data
90
-     * @access public
91
-     */
92
-    function sendPostData($url, $postdata, $ip=null, $timeout=10)
93
-    {
94
-        //set various curl options first
95
-        // set url to post to
96
-        curl_setopt($this->ch, CURLOPT_URL,$url);
97
-        // return into a variable rather than displaying it
98
-        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,true);
82
+	/**
83
+	 * Send post data to target URL     
84
+	 * return data returned from url or false if error occured
85
+	 * @param string url
86
+	 * @param mixed post data (assoc array ie. $foo['post_var_name'] = $value or as string like var=val1&var2=val2)
87
+	 * @param string ip address to bind (default null)
88
+	 * @param int timeout in sec for complete curl operation (default 10)
89
+	 * @return string data
90
+	 * @access public
91
+	 */
92
+	function sendPostData($url, $postdata, $ip=null, $timeout=10)
93
+	{
94
+		//set various curl options first
95
+		// set url to post to
96
+		curl_setopt($this->ch, CURLOPT_URL,$url);
97
+		// return into a variable rather than displaying it
98
+		curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,true);
99 99
         
100
-        //bind to specific ip address if it is sent trough arguments
101
-        if($ip) {
102
-            if($this->debug)
103
-            {
104
-                echo "Binding to ip $ip\n";
105
-            }
106
-            curl_setopt($this->ch,CURLOPT_INTERFACE,$ip);
107
-        }
100
+		//bind to specific ip address if it is sent trough arguments
101
+		if($ip) {
102
+			if($this->debug)
103
+			{
104
+				echo "Binding to ip $ip\n";
105
+			}
106
+			curl_setopt($this->ch,CURLOPT_INTERFACE,$ip);
107
+		}
108 108
         
109
-        //set curl function timeout to $timeout
110
-        curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
109
+		//set curl function timeout to $timeout
110
+		curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
111 111
         
112
-        //set method to post
113
-        curl_setopt($this->ch, CURLOPT_POST, true);
114
-        // set post string
115
-        curl_setopt($this->ch, CURLOPT_POSTFIELDS, $postdata);
112
+		//set method to post
113
+		curl_setopt($this->ch, CURLOPT_POST, true);
114
+		// set post string
115
+		curl_setopt($this->ch, CURLOPT_POSTFIELDS, $postdata);
116 116
         
117
-        //and finally send curl request
118
-        $result = curl_exec_redir($this->ch);
119
-        if(curl_errno($this->ch)) {
120
-            if($this->debug) {
121
-                echo "Error Occured in Curl\n";
122
-                echo "Error number: " .curl_errno($this->ch) ."\n";
123
-                echo "Error message: " .curl_error($this->ch)."\n";
124
-            }
125
-            return false;
126
-        } else {
127
-            return $result;
128
-        }
129
-    }
117
+		//and finally send curl request
118
+		$result = curl_exec_redir($this->ch);
119
+		if(curl_errno($this->ch)) {
120
+			if($this->debug) {
121
+				echo "Error Occured in Curl\n";
122
+				echo "Error number: " .curl_errno($this->ch) ."\n";
123
+				echo "Error message: " .curl_error($this->ch)."\n";
124
+			}
125
+			return false;
126
+		} else {
127
+			return $result;
128
+		}
129
+	}
130 130
     
131
-    /**
132
-     * fetch data from target URL     
133
-     * return data returned from url or false if error occured
134
-     * @param string url     
135
-     * @param string ip address to bind (default null)
136
-     * @param int timeout in sec for complete curl operation (default 5)
137
-     * @return string data
138
-     * @access public
139
-     */
140
-    function fetchUrl($url, $ip=null, $timeout=5)
141
-    {
142
-        // set url to post to
143
-        curl_setopt($this->ch, CURLOPT_URL,$url);
131
+	/**
132
+	 * fetch data from target URL     
133
+	 * return data returned from url or false if error occured
134
+	 * @param string url     
135
+	 * @param string ip address to bind (default null)
136
+	 * @param int timeout in sec for complete curl operation (default 5)
137
+	 * @return string data
138
+	 * @access public
139
+	 */
140
+	function fetchUrl($url, $ip=null, $timeout=5)
141
+	{
142
+		// set url to post to
143
+		curl_setopt($this->ch, CURLOPT_URL,$url);
144 144
         
145
-        //set method to get
146
-        curl_setopt($this->ch, CURLOPT_HTTPGET,true);
147
-        // return into a variable rather than displaying it
148
-        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,true);
145
+		//set method to get
146
+		curl_setopt($this->ch, CURLOPT_HTTPGET,true);
147
+		// return into a variable rather than displaying it
148
+		curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,true);
149 149
         
150
-        //bind to specific ip address if it is sent trough arguments
151
-        if($ip) {
152
-            if($this->debug) {
153
-                echo "Binding to ip $ip\n";
154
-            }
150
+		//bind to specific ip address if it is sent trough arguments
151
+		if($ip) {
152
+			if($this->debug) {
153
+				echo "Binding to ip $ip\n";
154
+			}
155 155
             
156
-            curl_setopt($this->ch,CURLOPT_INTERFACE,$ip);
157
-        }
156
+			curl_setopt($this->ch,CURLOPT_INTERFACE,$ip);
157
+		}
158 158
         
159
-        //set curl function timeout to $timeout
160
-        curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
159
+		//set curl function timeout to $timeout
160
+		curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
161 161
         
162
-        //and finally send curl request
163
-        $result = curl_exec_redir($this->ch);
164
-        if(curl_errno($this->ch)) {
165
-            if($this->debug) {
166
-                echo "Error Occured in Curl\n";
167
-                echo "Error number: " .curl_errno($this->ch) ."\n";
168
-                echo "Error message: " .curl_error($this->ch)."\n";
169
-            }
170
-            return false;
171
-        } else {
172
-            return $result;
173
-        }
174
-    }
162
+		//and finally send curl request
163
+		$result = curl_exec_redir($this->ch);
164
+		if(curl_errno($this->ch)) {
165
+			if($this->debug) {
166
+				echo "Error Occured in Curl\n";
167
+				echo "Error number: " .curl_errno($this->ch) ."\n";
168
+				echo "Error message: " .curl_error($this->ch)."\n";
169
+			}
170
+			return false;
171
+		} else {
172
+			return $result;
173
+		}
174
+	}
175 175
     
176
-    /**
177
-     * Fetch data from target URL
178
-     * and store it directly to file          
179
-     * @param string url     
180
-     * @param resource value stream resource(ie. fopen)
181
-     * @param string ip address to bind (default null)
182
-     * @param int timeout in sec for complete curl operation (default 5)
183
-     * @return boolean true on success false othervise
184
-     * @access public
185
-     */
186
-    function fetchIntoFile($url, $fp, $ip=null, $timeout=5)
187
-    {
188
-        // set url to post to
189
-        curl_setopt($this->ch, CURLOPT_URL,$url);
190
-        //set method to get
191
-        curl_setopt($this->ch, CURLOPT_HTTPGET, true);
192
-        // store data into file rather than displaying it
193
-        curl_setopt($this->ch, CURLOPT_FILE, $fp);
176
+	/**
177
+	 * Fetch data from target URL
178
+	 * and store it directly to file          
179
+	 * @param string url     
180
+	 * @param resource value stream resource(ie. fopen)
181
+	 * @param string ip address to bind (default null)
182
+	 * @param int timeout in sec for complete curl operation (default 5)
183
+	 * @return boolean true on success false othervise
184
+	 * @access public
185
+	 */
186
+	function fetchIntoFile($url, $fp, $ip=null, $timeout=5)
187
+	{
188
+		// set url to post to
189
+		curl_setopt($this->ch, CURLOPT_URL,$url);
190
+		//set method to get
191
+		curl_setopt($this->ch, CURLOPT_HTTPGET, true);
192
+		// store data into file rather than displaying it
193
+		curl_setopt($this->ch, CURLOPT_FILE, $fp);
194 194
         
195
-        //bind to specific ip address if it is sent trough arguments
196
-        if($ip) {
197
-            if($this->debug) {
198
-                echo "Binding to ip $ip\n";
199
-            }
200
-            curl_setopt($this->ch, CURLOPT_INTERFACE, $ip);
201
-        }
195
+		//bind to specific ip address if it is sent trough arguments
196
+		if($ip) {
197
+			if($this->debug) {
198
+				echo "Binding to ip $ip\n";
199
+			}
200
+			curl_setopt($this->ch, CURLOPT_INTERFACE, $ip);
201
+		}
202 202
         
203
-        //set curl function timeout to $timeout
204
-        curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
203
+		//set curl function timeout to $timeout
204
+		curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
205 205
         
206
-        //and finally send curl request
207
-        $result = curl_exec_redir($this->ch);
208
-        if(curl_errno($this->ch)) {
209
-            if($this->debug) {
210
-                echo "Error Occured in Curl\n";
211
-                echo "Error number: " .curl_errno($this->ch) ."\n";
212
-                echo "Error message: " .curl_error($this->ch)."\n";
213
-            }
206
+		//and finally send curl request
207
+		$result = curl_exec_redir($this->ch);
208
+		if(curl_errno($this->ch)) {
209
+			if($this->debug) {
210
+				echo "Error Occured in Curl\n";
211
+				echo "Error number: " .curl_errno($this->ch) ."\n";
212
+				echo "Error message: " .curl_error($this->ch)."\n";
213
+			}
214 214
             
215
-            return false;
216
-        } else  {
217
-            return true;
218
-        }
219
-    }
215
+			return false;
216
+		} else  {
217
+			return true;
218
+		}
219
+	}
220 220
     
221
-    /**
222
-     * Send multipart post data to the target URL     
223
-     * return data returned from url or false if error occured
224
-     * (contribution by vule nikolic, [email protected])
225
-     * @param string url
226
-     * @param array assoc post data array ie. $foo['post_var_name'] = $value
227
-     * @param array assoc $file_field_array, contains file_field name = value - path pairs
228
-     * @param string ip address to bind (default null)
229
-     * @param int timeout in sec for complete curl operation (default 30 sec)
230
-     * @return string data
231
-     * @access public
232
-     */
233
-    function sendMultipartPostData($url, $postdata, $file_field_array=array(), $ip=null, $timeout=30)
234
-    {
235
-        //set various curl options first
236
-        // set url to post to
237
-        curl_setopt($this->ch, CURLOPT_URL, $url);
238
-        // return into a variable rather than displaying it
239
-        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
221
+	/**
222
+	 * Send multipart post data to the target URL     
223
+	 * return data returned from url or false if error occured
224
+	 * (contribution by vule nikolic, [email protected])
225
+	 * @param string url
226
+	 * @param array assoc post data array ie. $foo['post_var_name'] = $value
227
+	 * @param array assoc $file_field_array, contains file_field name = value - path pairs
228
+	 * @param string ip address to bind (default null)
229
+	 * @param int timeout in sec for complete curl operation (default 30 sec)
230
+	 * @return string data
231
+	 * @access public
232
+	 */
233
+	function sendMultipartPostData($url, $postdata, $file_field_array=array(), $ip=null, $timeout=30)
234
+	{
235
+		//set various curl options first
236
+		// set url to post to
237
+		curl_setopt($this->ch, CURLOPT_URL, $url);
238
+		// return into a variable rather than displaying it
239
+		curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
240 240
         
241
-        //bind to specific ip address if it is sent trough arguments
242
-        if($ip) {
243
-            if($this->debug) {
244
-                echo "Binding to ip $ip\n";
245
-            }
241
+		//bind to specific ip address if it is sent trough arguments
242
+		if($ip) {
243
+			if($this->debug) {
244
+				echo "Binding to ip $ip\n";
245
+			}
246 246
             
247
-            curl_setopt($this->ch,CURLOPT_INTERFACE,$ip);
248
-        }
247
+			curl_setopt($this->ch,CURLOPT_INTERFACE,$ip);
248
+		}
249 249
         
250
-        //set curl function timeout to $timeout
251
-        curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
252
-        //set method to post
253
-        curl_setopt($this->ch, CURLOPT_POST, true);
254
-        // disable Expect header
255
-        // hack to make it working
256
-        $headers = array("Expect: ");
257
-        curl_setopt($this->ch, CURLOPT_HTTPHEADER, $headers);
258
-        // initialize result post array
259
-        $result_post = array();
260
-        //generate post string
261
-        $post_array = array();
262
-        $post_string_array = array();
250
+		//set curl function timeout to $timeout
251
+		curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
252
+		//set method to post
253
+		curl_setopt($this->ch, CURLOPT_POST, true);
254
+		// disable Expect header
255
+		// hack to make it working
256
+		$headers = array("Expect: ");
257
+		curl_setopt($this->ch, CURLOPT_HTTPHEADER, $headers);
258
+		// initialize result post array
259
+		$result_post = array();
260
+		//generate post string
261
+		$post_array = array();
262
+		$post_string_array = array();
263 263
         
264
-        if(!is_array($postdata)) {
265
-            return false;
266
-        }
264
+		if(!is_array($postdata)) {
265
+			return false;
266
+		}
267 267
         
268
-        foreach($postdata as $key=>$value) {
269
-            $post_array[$key] = $value;
270
-            $post_string_array[] = urlencode($key)."=".urlencode($value);
271
-        }
268
+		foreach($postdata as $key=>$value) {
269
+			$post_array[$key] = $value;
270
+			$post_string_array[] = urlencode($key)."=".urlencode($value);
271
+		}
272 272
         
273
-        $post_string = implode("&",$post_string_array);
274
-        if($this->debug) {
275
-            echo "Post String: $post_string\n";
276
-        }
273
+		$post_string = implode("&",$post_string_array);
274
+		if($this->debug) {
275
+			echo "Post String: $post_string\n";
276
+		}
277 277
         
278
-        // set post string
279
-        //curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_string);
280
-        // set multipart form data - file array field-value pairs
281
-        if(!empty($file_field_array)) {
282
-            foreach($file_field_array as $var_name => $var_value) {
283
-                if(strpos(PHP_OS, "WIN") !== false) $var_value = str_replace("/", "\\", $var_value); // win hack
284
-                $file_field_array[$var_name] = "@".$var_value;
285
-            }
286
-        }
278
+		// set post string
279
+		//curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_string);
280
+		// set multipart form data - file array field-value pairs
281
+		if(!empty($file_field_array)) {
282
+			foreach($file_field_array as $var_name => $var_value) {
283
+				if(strpos(PHP_OS, "WIN") !== false) $var_value = str_replace("/", "\\", $var_value); // win hack
284
+				$file_field_array[$var_name] = "@".$var_value;
285
+			}
286
+		}
287 287
         
288
-        // set post data
289
-        $result_post = array_merge($post_array, $file_field_array);
290
-        curl_setopt($this->ch, CURLOPT_POSTFIELDS, $result_post);
288
+		// set post data
289
+		$result_post = array_merge($post_array, $file_field_array);
290
+		curl_setopt($this->ch, CURLOPT_POSTFIELDS, $result_post);
291 291
         
292
-        //and finally send curl request
293
-        $result = curl_exec_redir($this->ch);
294
-        if(curl_errno($this->ch)) {
295
-            if($this->debug) {
296
-                echo "Error Occured in Curl\n";
297
-                echo "Error number: " .curl_errno($this->ch) ."\n";
298
-                echo "Error message: " .curl_error($this->ch)."\n";
299
-            }
292
+		//and finally send curl request
293
+		$result = curl_exec_redir($this->ch);
294
+		if(curl_errno($this->ch)) {
295
+			if($this->debug) {
296
+				echo "Error Occured in Curl\n";
297
+				echo "Error number: " .curl_errno($this->ch) ."\n";
298
+				echo "Error message: " .curl_error($this->ch)."\n";
299
+			}
300 300
             
301
-            return false;
302
-        } else {
303
-            return $result;
304
-        }
305
-    }
301
+			return false;
302
+		} else {
303
+			return $result;
304
+		}
305
+	}
306 306
     
307
-    /**
308
-     * Set file location where cookie data will be stored and send on each new request
309
-     * @param string absolute path to cookie file (must be in writable dir)
310
-     * @access public
311
-     */
312
-    function storeCookies($cookie_file)
313
-    {
314
-        // use cookies on each request (cookies stored in $cookie_file)
315
-        curl_setopt ($this->ch, CURLOPT_COOKIEJAR, $cookie_file);
316
-        curl_setopt ($this->ch, CURLOPT_COOKIEFILE, $cookie_file);
317
-    }
307
+	/**
308
+	 * Set file location where cookie data will be stored and send on each new request
309
+	 * @param string absolute path to cookie file (must be in writable dir)
310
+	 * @access public
311
+	 */
312
+	function storeCookies($cookie_file)
313
+	{
314
+		// use cookies on each request (cookies stored in $cookie_file)
315
+		curl_setopt ($this->ch, CURLOPT_COOKIEJAR, $cookie_file);
316
+		curl_setopt ($this->ch, CURLOPT_COOKIEFILE, $cookie_file);
317
+	}
318 318
     
319
-    /**
320
-     * Set custom cookie
321
-     * @param string cookie
322
-     * @access public
323
-     */
324
-    function setCookie($cookie)
325
-    {        
326
-        curl_setopt ($this->ch, CURLOPT_COOKIE, $cookie);
327
-    }
319
+	/**
320
+	 * Set custom cookie
321
+	 * @param string cookie
322
+	 * @access public
323
+	 */
324
+	function setCookie($cookie)
325
+	{        
326
+		curl_setopt ($this->ch, CURLOPT_COOKIE, $cookie);
327
+	}
328 328
     
329
-    /**
330
-     * Get last URL info 
331
-     * usefull when original url was redirected to other location    
332
-     * @access public
333
-     * @return string url
334
-     */
335
-    function getEffectiveUrl()
336
-    {
337
-        return curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL);
338
-    }
329
+	/**
330
+	 * Get last URL info 
331
+	 * usefull when original url was redirected to other location    
332
+	 * @access public
333
+	 * @return string url
334
+	 */
335
+	function getEffectiveUrl()
336
+	{
337
+		return curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL);
338
+	}
339 339
     
340
-    /**
341
-     * Get http response code     
342
-     * @access public
343
-     * @return int
344
-     */
345
-    function getHttpResponseCode()
346
-    {
347
-        return curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
348
-    }
340
+	/**
341
+	 * Get http response code     
342
+	 * @access public
343
+	 * @return int
344
+	 */
345
+	function getHttpResponseCode()
346
+	{
347
+		return curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
348
+	}
349 349
     
350
-    /**
351
-     * Return last error message and error number
352
-     * @return string error msg
353
-     * @access public
354
-     */
355
-    function getErrorMsg()
356
-    {
357
-        $err = "Error number: " .curl_errno($this->ch) ."\n";
358
-        $err .="Error message: " .curl_error($this->ch)."\n";
359
-        return $err;
360
-    }
350
+	/**
351
+	 * Return last error message and error number
352
+	 * @return string error msg
353
+	 * @access public
354
+	 */
355
+	function getErrorMsg()
356
+	{
357
+		$err = "Error number: " .curl_errno($this->ch) ."\n";
358
+		$err .="Error message: " .curl_error($this->ch)."\n";
359
+		return $err;
360
+	}
361 361
     
362
-    /**
363
-     * Close curl session and free resource
364
-     * Usually no need to call this function directly
365
-     * in case you do you have to call init() to recreate curl
366
-     * @access public
367
-     */
368
-    function close()
369
-    {
370
-        //close curl session and free up resources
371
-        curl_close($this->ch);
372
-    }
362
+	/**
363
+	 * Close curl session and free resource
364
+	 * Usually no need to call this function directly
365
+	 * in case you do you have to call init() to recreate curl
366
+	 * @access public
367
+	 */
368
+	function close()
369
+	{
370
+		//close curl session and free up resources
371
+		curl_close($this->ch);
372
+	}
373 373
 }
374 374
 
375 375
 /**
@@ -378,58 +378,58 @@  discard block
 block discarded – undo
378 378
  */
379 379
 function curlExecRedir($ch)
380 380
 {
381
-    static $curl_loops = 0;
382
-    static $curl_max_loops = 20;
381
+	static $curl_loops = 0;
382
+	static $curl_max_loops = 20;
383 383
     
384
-    if ($curl_loops++ >= $curl_max_loops) {
385
-        $curl_loops = 0;
386
-        return FALSE;
387
-    }
384
+	if ($curl_loops++ >= $curl_max_loops) {
385
+		$curl_loops = 0;
386
+		return FALSE;
387
+	}
388 388
     
389
-    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
390
-    curl_setopt($ch, CURLOPT_HEADER, true);
391
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
392
-    curl_setopt($ch, CURLOPT_VERBOSE, false);
393
-    $data = curl_exec($ch);
394
-    $data = str_replace("\r", "\n", str_replace("\r\n", "\n", $data));
395
-    list($header, $data) = explode("\n\n", $data, 2);
396
-    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
389
+	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
390
+	curl_setopt($ch, CURLOPT_HEADER, true);
391
+	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
392
+	curl_setopt($ch, CURLOPT_VERBOSE, false);
393
+	$data = curl_exec($ch);
394
+	$data = str_replace("\r", "\n", str_replace("\r\n", "\n", $data));
395
+	list($header, $data) = explode("\n\n", $data, 2);
396
+	$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
397 397
     
398
-    //echo "*** Got HTTP code: $http_code ***\n";
399
-    //echo "**  Got headers: \n$header\n\n";
398
+	//echo "*** Got HTTP code: $http_code ***\n";
399
+	//echo "**  Got headers: \n$header\n\n";
400 400
     
401
-    if ( $http_code == 301 || $http_code == 302 ) {
402
-        // If we're redirected, we should revert to GET
403
-        curl_setopt($ch, CURLOPT_HTTPGET,true);
401
+	if ( $http_code == 301 || $http_code == 302 ) {
402
+		// If we're redirected, we should revert to GET
403
+		curl_setopt($ch, CURLOPT_HTTPGET,true);
404 404
         
405
-        $matches = array();
406
-        preg_match('/Location:\s*(.*?)(\n|$)/i', $header, $matches);
407
-        $url = @parse_url(trim($matches[1]));
405
+		$matches = array();
406
+		preg_match('/Location:\s*(.*?)(\n|$)/i', $header, $matches);
407
+		$url = @parse_url(trim($matches[1]));
408 408
         
409
-        if (!$url) {
410
-            //couldn't process the url to redirect to
411
-            $curl_loops = 0;
412
-            return $data;
413
-        }
409
+		if (!$url) {
410
+			//couldn't process the url to redirect to
411
+			$curl_loops = 0;
412
+			return $data;
413
+		}
414 414
         
415
-        $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
416
-        if (empty($url['scheme']))
417
-            $url['scheme'] = $last_url['scheme'];
415
+		$last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
416
+		if (empty($url['scheme']))
417
+			$url['scheme'] = $last_url['scheme'];
418 418
         
419
-        if (empty($url['host']))
420
-            $url['host'] = $last_url['host'];
419
+		if (empty($url['host']))
420
+			$url['host'] = $last_url['host'];
421 421
         
422
-        if (empty($url['path']))
423
-            $url['path'] = $last_url['path'];
422
+		if (empty($url['path']))
423
+			$url['path'] = $last_url['path'];
424 424
         
425
-        $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:'');
426
-        //echo "Being redirected to $new_url\n";
427
-        curl_setopt($ch, CURLOPT_URL, $new_url);
425
+		$new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:'');
426
+		//echo "Being redirected to $new_url\n";
427
+		curl_setopt($ch, CURLOPT_URL, $new_url);
428 428
         
429
-        return curl_exec_redir($ch);
430
-    } else {
431
-        $curl_loops=0;
432
-        return $data;
433
-    }
429
+		return curl_exec_redir($ch);
430
+	} else {
431
+		$curl_loops=0;
432
+		return $data;
433
+	}
434 434
 }
435 435
 ?>
Please login to merge, or discard this patch.
src/Route4Me/RouteParameters.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -5,74 +5,74 @@
 block discarded – undo
5 5
 
6 6
 class RouteParameters extends Common
7 7
 {
8
-    public $is_upload;
9
-    public $rt;
10
-    public $route_name;
11
-    public $route_date;
12
-    public $route_time;
13
-    public $shared_publicly;
14
-    public $disable_optimization;
15
-    public $optimize;
16
-    public $lock_last;
17
-    public $vehicle_capacity;
18
-    public $vehicle_max_distance_mi;
19
-    public $distance_unit;
20
-    public $travel_mode;
21
-    public $avoid;
22
-    public $vehicle_id;
23
-    public $dev_lat;
24
-    public $dev_lng;
25
-    public $route_max_duration;
26
-    public $route_email;
27
-    public $route_type = "api";
28
-    public $store_route = true;
29
-    public $metric;
30
-    public $algorithm_type;
31
-    public $member_id;
32
-    public $ip;
33
-    public $dm;
34
-    public $dirm;
35
-    public $parts;
36
-    public $device_id;
37
-    public $device_type;
38
-    public $has_trailer;
39
-    public $trailer_weight_t;
40
-    public $limited_weight_t;
41
-    public $weight_per_axle_t;
42
-    public $truck_height_meters;
43
-    public $truck_width_meters;
44
-    public $truck_length_meters;
45
-    public $truck_hazardous_goods;
8
+	public $is_upload;
9
+	public $rt;
10
+	public $route_name;
11
+	public $route_date;
12
+	public $route_time;
13
+	public $shared_publicly;
14
+	public $disable_optimization;
15
+	public $optimize;
16
+	public $lock_last;
17
+	public $vehicle_capacity;
18
+	public $vehicle_max_distance_mi;
19
+	public $distance_unit;
20
+	public $travel_mode;
21
+	public $avoid;
22
+	public $vehicle_id;
23
+	public $dev_lat;
24
+	public $dev_lng;
25
+	public $route_max_duration;
26
+	public $route_email;
27
+	public $route_type = "api";
28
+	public $store_route = true;
29
+	public $metric;
30
+	public $algorithm_type;
31
+	public $member_id;
32
+	public $ip;
33
+	public $dm;
34
+	public $dirm;
35
+	public $parts;
36
+	public $device_id;
37
+	public $device_type;
38
+	public $has_trailer;
39
+	public $trailer_weight_t;
40
+	public $limited_weight_t;
41
+	public $weight_per_axle_t;
42
+	public $truck_height_meters;
43
+	public $truck_width_meters;
44
+	public $truck_length_meters;
45
+	public $truck_hazardous_goods;
46 46
     
47
-    public $vehicle_max_cargo_weight;
48
-    public $vehicle_max_cargo_volume;
49
-    public $subtour_max_revenue;
50
-    public $avoidance_zones;
51
-    public $driver_id;
52
-    public $parts_min;
53
-    public $first_drive_then_wait_between_stops;
54
-    public $truck_height;
55
-    public $truck_width;
56
-    public $truck_length;
57
-    public $optimization_quality;
58
-    public $override_addresses;
59
-    public $max_tour_size;
60
-    public $min_tour_size;
61
-    public $uturn;
62
-    public $leftturn;
63
-    public $rightturn;
47
+	public $vehicle_max_cargo_weight;
48
+	public $vehicle_max_cargo_volume;
49
+	public $subtour_max_revenue;
50
+	public $avoidance_zones;
51
+	public $driver_id;
52
+	public $parts_min;
53
+	public $first_drive_then_wait_between_stops;
54
+	public $truck_height;
55
+	public $truck_width;
56
+	public $truck_length;
57
+	public $optimization_quality;
58
+	public $override_addresses;
59
+	public $max_tour_size;
60
+	public $min_tour_size;
61
+	public $uturn;
62
+	public $leftturn;
63
+	public $rightturn;
64 64
     
65
-    public $optimized_callback_url;
65
+	public $optimized_callback_url;
66 66
 
67
-    public static function fromArray(array $params)
68
-    {
69
-        $routeParams = new RouteParameters();
70
-        foreach($params as $key => $value) {
71
-            if (property_exists($routeParams, $key)) {
72
-                $routeParams->{$key} = $value;
73
-            }
74
-        }
67
+	public static function fromArray(array $params)
68
+	{
69
+		$routeParams = new RouteParameters();
70
+		foreach($params as $key => $value) {
71
+			if (property_exists($routeParams, $key)) {
72
+				$routeParams->{$key} = $value;
73
+			}
74
+		}
75 75
 
76
-        return $routeParams;
77
-    }
76
+		return $routeParams;
77
+	}
78 78
 }
Please login to merge, or discard this patch.
src/Route4Me/Enum/Metric.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@
 block discarded – undo
3 3
 
4 4
 class Metric
5 5
 {
6
-    const EUCLIDEAN = 1; //measures point to point distance as a straight line
7
-    const MANHATTAN = 2; //measures point to point distance as taxicab geometry line
8
-    const GEODESIC  = 3; //measures point to point distance approximating curvature of the earth
9
-    const MATRIX    = 4; //measures point to point distance by traversing the actual road network
10
-    const EXACT_2D  = 5; //measures point to point distance using 2d rectilinear distance
6
+	const EUCLIDEAN = 1; //measures point to point distance as a straight line
7
+	const MANHATTAN = 2; //measures point to point distance as taxicab geometry line
8
+	const GEODESIC  = 3; //measures point to point distance approximating curvature of the earth
9
+	const MATRIX    = 4; //measures point to point distance by traversing the actual road network
10
+	const EXACT_2D  = 5; //measures point to point distance using 2d rectilinear distance
11 11
 }
Please login to merge, or discard this patch.