GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 49fd2d...63bb85 )
by Oleg
02:40 queued 42s
created
src/Route4Me/AddressBookLocation.php 1 patch
Indentation   +371 added lines, -371 removed lines patch added patch discarded remove patch
@@ -6,452 +6,452 @@
 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 65
     
66 66
     
67
-    public static function getAddressBookLocation($addressId)
68
-    {
69
-        $ablocations = Route4Me::makeRequst(array(
70
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
71
-            'method' => 'GET',
72
-            'query'  => array(
73
-                'query' => $addressId,
74
-                'limit' => 30
75
-            )
76
-        ));
67
+	public static function getAddressBookLocation($addressId)
68
+	{
69
+		$ablocations = Route4Me::makeRequst(array(
70
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
71
+			'method' => 'GET',
72
+			'query'  => array(
73
+				'query' => $addressId,
74
+				'limit' => 30
75
+			)
76
+		));
77 77
 
78
-        return $ablocations;
79
-    }
78
+		return $ablocations;
79
+	}
80 80
     
81
-    public static function searchAddressBookLocations($params)
82
-    {
83
-        $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset');
81
+	public static function searchAddressBookLocations($params)
82
+	{
83
+		$allQueryFields = array('display', 'query', 'fields', 'limit', 'offset');
84 84
         
85
-        $result = Route4Me::makeRequst(array(
86
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
87
-            'method' => 'GET',
88
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
89
-        ));
85
+		$result = Route4Me::makeRequst(array(
86
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
87
+			'method' => 'GET',
88
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
89
+		));
90 90
 
91
-        return $result;
92
-    }
91
+		return $result;
92
+	}
93 93
     
94
-    public static function getAddressBookLocations($params)
95
-    {
96
-        $allQueryFields = array('limit', 'offset', 'address_id');
94
+	public static function getAddressBookLocations($params)
95
+	{
96
+		$allQueryFields = array('limit', 'offset', 'address_id');
97 97
         
98
-        $ablocations = Route4Me::makeRequst(array(
99
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
100
-            'method' => 'GET',
101
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
102
-        ));
98
+		$ablocations = Route4Me::makeRequst(array(
99
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
100
+			'method' => 'GET',
101
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
102
+		));
103 103
 
104
-        return $ablocations;
105
-    }
104
+		return $ablocations;
105
+	}
106 106
     
107
-    public static function getRandomAddressBookLocation($params)
108
-    {
109
-        $ablocations = self::getAddressBookLocations($params);
107
+	public static function getRandomAddressBookLocation($params)
108
+	{
109
+		$ablocations = self::getAddressBookLocations($params);
110 110
         
111
-        if (isset($ablocations["results"])) {
112
-            $locationsSize = sizeof($ablocations["results"]);
111
+		if (isset($ablocations["results"])) {
112
+			$locationsSize = sizeof($ablocations["results"]);
113 113
             
114
-            if ($locationsSize>0) {
115
-                $randomLocationIndex = rand(0, $locationsSize - 1);
116
-                return $ablocations["results"][$randomLocationIndex];
117
-            } 
118
-        } 
114
+			if ($locationsSize>0) {
115
+				$randomLocationIndex = rand(0, $locationsSize - 1);
116
+				return $ablocations["results"][$randomLocationIndex];
117
+			} 
118
+		} 
119 119
 
120
-        return null;
121
-    }
120
+		return null;
121
+	}
122 122
     
123
-    /**
124
-     * @param AddressBookLocation $params
125
-    */
126
-    public static function addAdressBookLocation($params)
127
-    {
128
-        $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count'));
123
+	/**
124
+	 * @param AddressBookLocation $params
125
+	 */
126
+	public static function addAdressBookLocation($params)
127
+	{
128
+		$allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count'));
129 129
         
130
-        $response = Route4Me::makeRequst(array(
131
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
132
-            'method' => 'POST',
133
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
134
-        ));
130
+		$response = Route4Me::makeRequst(array(
131
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
132
+			'method' => 'POST',
133
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
134
+		));
135 135
 
136
-        return $response;
137
-    }
136
+		return $response;
137
+	}
138 138
     
139
-    public function deleteAdressBookLocation($address_ids)
140
-    {
141
-        $result = Route4Me::makeRequst(array(
142
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
143
-            'method' => 'DELETEARRAY',
144
-            'query'  => array(
145
-                'address_ids' => $address_ids
146
-            )
147
-        ));
139
+	public function deleteAdressBookLocation($address_ids)
140
+	{
141
+		$result = Route4Me::makeRequst(array(
142
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
143
+			'method' => 'DELETEARRAY',
144
+			'query'  => array(
145
+				'address_ids' => $address_ids
146
+			)
147
+		));
148 148
 
149
-        return $result;
150
-    }
149
+		return $result;
150
+	}
151 151
     
152
-    public function updateAdressBookLocation($params)
153
-    {
154
-        $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count'));
152
+	public function updateAdressBookLocation($params)
153
+	{
154
+		$allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count'));
155 155
 
156
-        $response = Route4Me::makeRequst(array(
157
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
158
-            'method' => 'PUT',
159
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
160
-        ));
156
+		$response = Route4Me::makeRequst(array(
157
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
158
+			'method' => 'PUT',
159
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
160
+		));
161 161
 
162
-        return $response;
163
-    }
162
+		return $response;
163
+	}
164 164
         
165
-    public static function validateScheduleMode($scheduleMode)
166
-    {
167
-        $schedMmodes = array("daily", "weekly", "monthly", "annually");
165
+	public static function validateScheduleMode($scheduleMode)
166
+	{
167
+		$schedMmodes = array("daily", "weekly", "monthly", "annually");
168 168
         
169
-        if (in_array($scheduleMode, $schedMmodes)) {
170
-            return TRUE; 
171
-        } else {
172
-            return FALSE;
173
-        }
174
-    }
169
+		if (in_array($scheduleMode, $schedMmodes)) {
170
+			return TRUE; 
171
+		} else {
172
+			return FALSE;
173
+		}
174
+	}
175 175
     
176
-    public static function validateScheduleEnable($scheduleEnabled)
177
-    {
178
-        $schedEnables = array(TRUE, FALSE);
176
+	public static function validateScheduleEnable($scheduleEnabled)
177
+	{
178
+		$schedEnables = array(TRUE, FALSE);
179 179
         
180
-        if (in_array($scheduleEnabled, $schedEnables)) {
181
-            return TRUE;
182
-        } else {
183
-            return FALSE;
184
-        }
185
-    }
180
+		if (in_array($scheduleEnabled, $schedEnables)) {
181
+			return TRUE;
182
+		} else {
183
+			return FALSE;
184
+		}
185
+	}
186 186
     
187
-    public static function validateScheduleEvery($scheduleEvery)
188
-    {
189
-        if (is_numeric($scheduleEvery)) {
190
-            return TRUE;
191
-        } else {
192
-            return FALSE;
193
-        }
194
-    }
187
+	public static function validateScheduleEvery($scheduleEvery)
188
+	{
189
+		if (is_numeric($scheduleEvery)) {
190
+			return TRUE;
191
+		} else {
192
+			return FALSE;
193
+		}
194
+	}
195 195
     
196
-    public static function validateScheduleWeekDays($scheduleWeekDays)
197
-    {
198
-        $weekdays = explode(',', $scheduleWeekDays);
199
-        $weekdaysSize = sizeof($weekdays);
196
+	public static function validateScheduleWeekDays($scheduleWeekDays)
197
+	{
198
+		$weekdays = explode(',', $scheduleWeekDays);
199
+		$weekdaysSize = sizeof($weekdays);
200 200
         
201
-        if ($weekdaysSize<1) {
202
-            return FALSE;
203
-        }
201
+		if ($weekdaysSize<1) {
202
+			return FALSE;
203
+		}
204 204
         
205
-        $isValid = TRUE;
205
+		$isValid = TRUE;
206 206
         
207
-        for ($i = 0; $i<$weekdaysSize; $i++) { 
208
-            if (is_numeric($weekdays[$i])) {
209
-                $wday = intval($weekdays[$i]);
210
-                if ($wday<1 || $wday>7) {
211
-                    $isValid = FALSE;
212
-                }
213
-            } else {
214
-                $isValid = FALSE;
215
-            }
216
-        }
207
+		for ($i = 0; $i<$weekdaysSize; $i++) { 
208
+			if (is_numeric($weekdays[$i])) {
209
+				$wday = intval($weekdays[$i]);
210
+				if ($wday<1 || $wday>7) {
211
+					$isValid = FALSE;
212
+				}
213
+			} else {
214
+				$isValid = FALSE;
215
+			}
216
+		}
217 217
         
218
-        return $isValid;
219
-    }
218
+		return $isValid;
219
+	}
220 220
     
221
-    public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
222
-    {
223
-        $schedMonthlyMmodes = array("dates", "nth");
221
+	public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
222
+	{
223
+		$schedMonthlyMmodes = array("dates", "nth");
224 224
         
225
-        if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) {
226
-            return TRUE;
227
-        } else {
228
-            return FALSE;
229
-        }
230
-    }
225
+		if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) {
226
+			return TRUE;
227
+		} else {
228
+			return FALSE;
229
+		}
230
+	}
231 231
     
232
-    public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
233
-    {
234
-        $monthlyDates = explode(',', $scheduleMonthlyDates);
235
-        $monthlyDatesSize = sizeof($monthlyDates);
232
+	public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
233
+	{
234
+		$monthlyDates = explode(',', $scheduleMonthlyDates);
235
+		$monthlyDatesSize = sizeof($monthlyDates);
236 236
         
237
-        if ($monthlyDatesSize<1) {
238
-            return FALSE;
239
-        }
237
+		if ($monthlyDatesSize<1) {
238
+			return FALSE;
239
+		}
240 240
         
241
-        $isValid = TRUE;
241
+		$isValid = TRUE;
242 242
         
243
-        for ($i = 0; $i<$monthlyDatesSize; $i++) { 
244
-            if (is_numeric($monthlyDates[$i])) {
245
-                $mday = intval($monthlyDates[$i]);
246
-                if ($mday<1 || $mday>31) {
247
-                    $isValid = FALSE;
248
-                }
249
-            } else {
250
-                $isValid = FALSE;
251
-            }
252
-        }
243
+		for ($i = 0; $i<$monthlyDatesSize; $i++) { 
244
+			if (is_numeric($monthlyDates[$i])) {
245
+				$mday = intval($monthlyDates[$i]);
246
+				if ($mday<1 || $mday>31) {
247
+					$isValid = FALSE;
248
+				}
249
+			} else {
250
+				$isValid = FALSE;
251
+			}
252
+		}
253 253
 
254
-        return $isValid;
255
-    }
254
+		return $isValid;
255
+	}
256 256
     
257
-    public static function validateScheduleNthN($scheduleNthN)
258
-    {
259
-        if (!is_numeric($scheduleNthN)) {
260
-            return FALSE;
261
-        }
257
+	public static function validateScheduleNthN($scheduleNthN)
258
+	{
259
+		if (!is_numeric($scheduleNthN)) {
260
+			return FALSE;
261
+		}
262 262
         
263
-        $schedNthNs = array(1, 2, 3, 4, 5, -1);
263
+		$schedNthNs = array(1, 2, 3, 4, 5, -1);
264 264
         
265
-        if (in_array($scheduleNthN, $schedNthNs)) {
266
-            return TRUE;
267
-        } else {
268
-            return FALSE;
269
-        }
270
-    }
265
+		if (in_array($scheduleNthN, $schedNthNs)) {
266
+			return TRUE;
267
+		} else {
268
+			return FALSE;
269
+		}
270
+	}
271 271
     
272
-    public static function validateScheduleNthWhat($scheduleNthWhat)
273
-    {
274
-        if (!is_numeric($scheduleNthWhat)) {
275
-            return FALSE;
276
-        }
272
+	public static function validateScheduleNthWhat($scheduleNthWhat)
273
+	{
274
+		if (!is_numeric($scheduleNthWhat)) {
275
+			return FALSE;
276
+		}
277 277
         
278
-        $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
278
+		$schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
279 279
         
280
-        if (in_array($scheduleNthWhat, $schedNthWhats)) {
281
-            return TRUE;
282
-        } else {
283
-            return FALSE;
284
-        }
285
-    }
280
+		if (in_array($scheduleNthWhat, $schedNthWhats)) {
281
+			return TRUE;
282
+		} else {
283
+			return FALSE;
284
+		}
285
+	}
286 286
     
287
-    /** Function adds the locations (with/without schedule) from the CSV file. 
288
-     * $csvFileHandle - a file handler.
289
-     * Returns array $results which contains two arrays: fail and succes.
290
-     */
291
-    public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
292
-    {
293
-        $max_line_length = 512;
294
-        $delemietr = ',';
287
+	/** Function adds the locations (with/without schedule) from the CSV file. 
288
+	 * $csvFileHandle - a file handler.
289
+	 * Returns array $results which contains two arrays: fail and succes.
290
+	 */
291
+	public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
292
+	{
293
+		$max_line_length = 512;
294
+		$delemietr = ',';
295 295
         
296
-        $results = array();
297
-        $results['fail'] = array();
298
-        $results['success'] = array();
296
+		$results = array();
297
+		$results['fail'] = array();
298
+		$results['success'] = array();
299 299
         
300
-        $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
300
+		$columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
301 301
         
302
-        $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count'));
302
+		$addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count'));
303 303
 
304
-        if (empty($columns)) {
305
-            array_push($results['fail'], 'Empty CSV table');
306
-            return ($results);
307
-        }
304
+		if (empty($columns)) {
305
+			array_push($results['fail'], 'Empty CSV table');
306
+			return ($results);
307
+		}
308 308
 
309
-        $iRow = 1;
309
+		$iRow = 1;
310 310
         
311
-        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) {
312
-            if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) 
313
-                  || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) {
314
-                continue;
315
-            }
311
+		while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) {
312
+			if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) 
313
+				  || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) {
314
+				continue;
315
+			}
316 316
                       
317
-            $curSchedule = "";
318
-            $mode = "";
317
+			$curSchedule = "";
318
+			$mode = "";
319 319
             
320
-            $failCount = sizeof($results['fail']); 
320
+			$failCount = sizeof($results['fail']); 
321 321
             
322
-            if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
323
-                if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
324
-                    $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
325
-                    $mode = $rows[$locationsFieldsMapping['schedule_mode']];
326
-                } else {
327
-                    array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); 
328
-                }
329
-            } else {
330
-                array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); 
331
-            }
322
+			if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
323
+				if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
324
+					$curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
325
+					$mode = $rows[$locationsFieldsMapping['schedule_mode']];
326
+				} else {
327
+					array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); 
328
+				}
329
+			} else {
330
+				array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); 
331
+			}
332 332
             
333
-            if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
334
-                if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
335
-                    $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
336
-                } else {
337
-                    array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set ");  
338
-                }
339
-            }
333
+			if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
334
+				if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
335
+					$curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
336
+				} else {
337
+					array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set ");  
338
+				}
339
+			}
340 340
             
341
-            if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
342
-                if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
343
-                    $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
344
-                    if ($mode=='daily') {
345
-                        $curSchedule = trim($curSchedule, ',');
346
-                        $curSchedule .= '}';
347
-                    }
348
-                } else {
349
-                    array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); 
350
-                }
351
-            }
341
+			if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
342
+				if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
343
+					$curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
344
+					if ($mode=='daily') {
345
+						$curSchedule = trim($curSchedule, ',');
346
+						$curSchedule .= '}';
347
+					}
348
+				} else {
349
+					array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); 
350
+				}
351
+			}
352 352
             
353
-            if ($mode!='daily') {
354
-                switch ($mode) {
355
-                    case 'weekly':
356
-                        if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
357
-                            if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
358
-                                 $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
359
-                            } else {
360
-                                array_push($results['fail'], "$iRow --> Wrong weekdays"); 
361
-                            }
362
-                        } else {
363
-                            array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); 
364
-                        }
365
-                        break;
366
-                    case 'monthly':
367
-                        $monthlyMode = "";
368
-                        if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
369
-                            if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
370
-                                 $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
371
-                                 $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
372
-                            } else {
373
-                                array_push($results['fail'], "$iRow --> Wrong monthly mode"); 
374
-                            }
375
-                        } else {
376
-                            array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); 
377
-                        }
353
+			if ($mode!='daily') {
354
+				switch ($mode) {
355
+					case 'weekly':
356
+						if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
357
+							if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
358
+								 $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
359
+							} else {
360
+								array_push($results['fail'], "$iRow --> Wrong weekdays"); 
361
+							}
362
+						} else {
363
+							array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); 
364
+						}
365
+						break;
366
+					case 'monthly':
367
+						$monthlyMode = "";
368
+						if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
369
+							if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
370
+								 $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
371
+								 $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
372
+							} else {
373
+								array_push($results['fail'], "$iRow --> Wrong monthly mode"); 
374
+							}
375
+						} else {
376
+							array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); 
377
+						}
378 378
                         
379
-                        if ($monthlyMode!="") {
380
-                            switch ($monthlyMode) {
381
-                                case 'dates':
382
-                                    if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
383
-                                        if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
384
-                                             $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
385
-                                        } else {
386
-                                            array_push($results['fail'], "$iRow --> Wrong monthly dates"); 
387
-                                        }
388
-                                    }
389
-                                    break;
390
-                                case 'nth':
391
-                                    if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
392
-                                        if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
393
-                                             $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
394
-                                        } else {
395
-                                            array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); 
396
-                                        }
397
-                                    } else {
398
-                                        array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); 
399
-                                    }
379
+						if ($monthlyMode!="") {
380
+							switch ($monthlyMode) {
381
+								case 'dates':
382
+									if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
383
+										if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
384
+											 $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
385
+										} else {
386
+											array_push($results['fail'], "$iRow --> Wrong monthly dates"); 
387
+										}
388
+									}
389
+									break;
390
+								case 'nth':
391
+									if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
392
+										if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
393
+											 $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
394
+										} else {
395
+											array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); 
396
+										}
397
+									} else {
398
+										array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); 
399
+									}
400 400
                                     
401
-                                    if ($curSchedule!="") {
402
-                                        if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
403
-                                            if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
404
-                                                 $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
405
-                                            } else {
406
-                                                array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); 
407
-                                            }
408
-                                        } else {
409
-                                            array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); 
410
-                                        }
411
-                                    }
412
-                                    break;
413
-                            }
414
-                        }
415
-                        break;
416
-                    default:
417
-                        $curSchedule = "";
418
-                        break;
419
-                }
420
-            }
401
+									if ($curSchedule!="") {
402
+										if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
403
+											if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
404
+												 $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
405
+											} else {
406
+												array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); 
407
+											}
408
+										} else {
409
+											array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); 
410
+										}
411
+									}
412
+									break;
413
+							}
414
+						}
415
+						break;
416
+					default:
417
+						$curSchedule = "";
418
+						break;
419
+				}
420
+			}
421 421
 
422
-            if (sizeof($results['fail'])>$failCount) {
423
-                $curSchedule = "";
424
-            }
422
+			if (sizeof($results['fail'])>$failCount) {
423
+				$curSchedule = "";
424
+			}
425 425
 
426
-            if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {
427
-                $iRow++; 
428
-                continue;
429
-            }
426
+			if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {
427
+				$iRow++; 
428
+				continue;
429
+			}
430 430
             
431
-            $curSchedule = strtolower($curSchedule);
431
+			$curSchedule = strtolower($curSchedule);
432 432
             
433
-            $curSchedule = '[{'.$curSchedule.'}]';
433
+			$curSchedule = '[{'.$curSchedule.'}]';
434 434
 
435
-            $oSchedule = json_decode($curSchedule, TRUE);
435
+			$oSchedule = json_decode($curSchedule, TRUE);
436 436
             
437
-            $parametersArray = array();
437
+			$parametersArray = array();
438 438
             
439
-            foreach ($addressBookFields as $addressBookField) {
440
-                if (isset($locationsFieldsMapping[$addressBookField])) {
441
-                    $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]];
442
-                }
443
-            }
439
+			foreach ($addressBookFields as $addressBookField) {
440
+				if (isset($locationsFieldsMapping[$addressBookField])) {
441
+					$parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]];
442
+				}
443
+			}
444 444
             
445
-            $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray);
445
+			$AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray);
446 446
             
447
-            $abContacts = new AddressBookLocation();
447
+			$abContacts = new AddressBookLocation();
448 448
 
449
-            $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
449
+			$abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
450 450
             
451
-            array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
452
-        }
451
+			array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
452
+		}
453 453
 
454
-        return $results;
455
-    }
454
+		return $results;
455
+	}
456 456
  }
457 457
  
458 458
\ No newline at end of file
Please login to merge, or discard this patch.
examples/multiple_depot_multiple_driver.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,20 +26,20 @@
 block discarded – undo
26 26
 
27 27
 $addresses = array();
28 28
 foreach ($json as $address) {
29
-    $addresses[] = Address::fromArray($address);
29
+	$addresses[] = Address::fromArray($address);
30 30
 }
31 31
 
32 32
 $parameters = RouteParameters::fromArray(array(
33
-    "algorithm_type"          => AlgorithmType::CVRP_TW_SD,
34
-    "distance_unit"           => DistanceUnit::MILES,
35
-    "device_type"             => DeviceType::WEB,
36
-    "optimize"                => OptimizationType::DISTANCE,
37
-    "metric"                  => Metric::GEODESIC,
38
-    "route_max_duration"      => 86400 * 2,
39
-    "travel_mode"             => TravelMode::DRIVING,
40
-    "vehicle_capacity"        => 50,
41
-    "vehicle_max_distance_mi" => 10000,
42
-    "parts"                   => 50
33
+	"algorithm_type"          => AlgorithmType::CVRP_TW_SD,
34
+	"distance_unit"           => DistanceUnit::MILES,
35
+	"device_type"             => DeviceType::WEB,
36
+	"optimize"                => OptimizationType::DISTANCE,
37
+	"metric"                  => Metric::GEODESIC,
38
+	"route_max_duration"      => 86400 * 2,
39
+	"travel_mode"             => TravelMode::DRIVING,
40
+	"vehicle_capacity"        => 50,
41
+	"vehicle_max_distance_mi" => 10000,
42
+	"parts"                   => 50
43 43
 ));
44 44
 
45 45
 $optimizationParams = new OptimizationProblemParams;
Please login to merge, or discard this patch.
examples/SingleDriverMultipleTimeWindows.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
 
26 26
 $addresses = array();
27 27
 foreach ($json as $address) {
28
-    $addresses[] = Address::fromArray($address);
28
+	$addresses[] = Address::fromArray($address);
29 29
 }
30 30
 
31 31
 $parameters = RouteParameters::fromArray(array(
32
-    "algorithm_type"     => Algorithmtype::TSP,
33
-    "route_name"         => "Single Driver Multiple TimeWindows 12 Stops",
34
-    "route_date"         => time() + 24 * 60 * 60,
35
-    "route_time"         => 5 * 3600 + 30 * 60,
36
-    "distance_unit"      => DistanceUnit::MILES,
37
-    "device_type"        => DeviceType::WEB,
38
-    "optimize"           => OptimizationType::DISTANCE,
39
-    "metric"             => Metric::GEODESIC
32
+	"algorithm_type"     => Algorithmtype::TSP,
33
+	"route_name"         => "Single Driver Multiple TimeWindows 12 Stops",
34
+	"route_date"         => time() + 24 * 60 * 60,
35
+	"route_time"         => 5 * 3600 + 30 * 60,
36
+	"distance_unit"      => DistanceUnit::MILES,
37
+	"device_type"        => DeviceType::WEB,
38
+	"optimize"           => OptimizationType::DISTANCE,
39
+	"metric"             => Metric::GEODESIC
40 40
 ));
41 41
 
42 42
 $optimizationParams = new OptimizationProblemParams;
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 $problem = OptimizationProblem::optimize($optimizationParams);
47 47
 
48 48
 foreach ((array)$problem as $key => $value) {
49
-    if (is_string($value)) {
50
-        echo $key." --> ".$value."<br>";
51
-    } else {
52
-        echo "************ $key ************* <br>";
53
-        Route4Me::simplePrint((array)$value, true);
54
-        echo "******************************* <br>";
55
-    }
49
+	if (is_string($value)) {
50
+		echo $key." --> ".$value."<br>";
51
+	} else {
52
+		echo "************ $key ************* <br>";
53
+		Route4Me::simplePrint((array)$value, true);
54
+		echo "******************************* <br>";
55
+	}
56 56
 }
Please login to merge, or discard this patch.
examples/SingleDepotMultipleDriverNoTimeWindow.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -26,24 +26,24 @@  discard block
 block discarded – undo
26 26
 
27 27
 $addresses = array();
28 28
 foreach ($json as $address) {
29
-    $addresses[] = Address::fromArray($address);
29
+	$addresses[] = Address::fromArray($address);
30 30
 }
31 31
 
32 32
 $parameters = RouteParameters::fromArray(array(
33
-    "algorithm_type"          => Algorithmtype::CVRP_TW_SD,
34
-    "route_name"              => "Single Depot, Multiple Driver, No Time Window",
35
-    "route_date"              => time() + 24 * 60 * 60,
36
-    "route_time"              => 60 * 60 * 7,
37
-    "rt"                      => TRUE,
38
-    "distance_unit"           => DistanceUnit::MILES,
39
-    "device_type"             => DeviceType::WEB,
40
-    "optimize"                => OptimizationType::TIME,
41
-    "metric"                  => Metric::GEODESIC,
42
-    "route_max_duration"      => 86400,
43
-    "travel_mode"             => TravelMode::DRIVING,
44
-    "vehicle_capacity"        => 20,
45
-    "vehicle_max_distance_mi" => 99999,
46
-    "parts"                   => 4
33
+	"algorithm_type"          => Algorithmtype::CVRP_TW_SD,
34
+	"route_name"              => "Single Depot, Multiple Driver, No Time Window",
35
+	"route_date"              => time() + 24 * 60 * 60,
36
+	"route_time"              => 60 * 60 * 7,
37
+	"rt"                      => TRUE,
38
+	"distance_unit"           => DistanceUnit::MILES,
39
+	"device_type"             => DeviceType::WEB,
40
+	"optimize"                => OptimizationType::TIME,
41
+	"metric"                  => Metric::GEODESIC,
42
+	"route_max_duration"      => 86400,
43
+	"travel_mode"             => TravelMode::DRIVING,
44
+	"vehicle_capacity"        => 20,
45
+	"vehicle_max_distance_mi" => 99999,
46
+	"parts"                   => 4
47 47
 ));
48 48
 
49 49
 $optimizationParams = new OptimizationProblemParams;
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 $problem = OptimizationProblem::optimize($optimizationParams);
54 54
 
55 55
 foreach ((array)$problem as $key => $value) {
56
-    if (is_string($value)) {
57
-        echo $key." --> ".$value."<br>";
58
-    } else {
59
-        echo "************ $key ************* <br>";
60
-        Route4Me::simplePrint((array)$value, true);
61
-        echo "******************************* <br>";
62
-    }
56
+	if (is_string($value)) {
57
+		echo $key." --> ".$value."<br>";
58
+	} else {
59
+		echo "************ $key ************* <br>";
60
+		Route4Me::simplePrint((array)$value, true);
61
+		echo "******************************* <br>";
62
+	}
63 63
 }
Please login to merge, or discard this patch.
examples/single_driver_round_trip.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
 $addresses = array();
28 28
 
29 29
 foreach ($json as $address) {
30
-    $addresses[] = Address::fromArray($address);
30
+	$addresses[] = Address::fromArray($address);
31 31
 }
32 32
 
33 33
 $parameters = RouteParameters::fromArray(array(
34
-    "algorithm_type"          => AlgorithmType::TSP,
35
-    "distance_unit"           => DistanceUnit::MILES,
36
-    "device_type"             => DeviceType::WEB,
37
-    "optimize"                => OptimizationType::DISTANCE,
38
-    "travel_mode"             => TravelMode::DRIVING,
39
-    "route_max_duration"      => 86400,
40
-    "vehicle_capacity"        => 1,
41
-    "vehicle_max_distance_mi" => 10000,
42
-    "rt"                      => true
34
+	"algorithm_type"          => AlgorithmType::TSP,
35
+	"distance_unit"           => DistanceUnit::MILES,
36
+	"device_type"             => DeviceType::WEB,
37
+	"optimize"                => OptimizationType::DISTANCE,
38
+	"travel_mode"             => TravelMode::DRIVING,
39
+	"route_max_duration"      => 86400,
40
+	"vehicle_capacity"        => 1,
41
+	"vehicle_max_distance_mi" => 10000,
42
+	"rt"                      => true
43 43
 ));
44 44
 
45 45
 $optimizationParams = new OptimizationProblemParams;
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 $problems = OptimizationProblem::optimize($optimizationParams);
50 50
 
51 51
 foreach ($problems as $problem) {
52
-    if (is_array($problem) || is_object($problem)) {
53
-        foreach ($problem as $key => $value) {
54
-            if (!is_object($value)) {
55
-                echo $key." --> ".$value."<br>";
56
-            }
57
-        }
58
-    }
52
+	if (is_array($problem) || is_object($problem)) {
53
+		foreach ($problem as $key => $value) {
54
+			if (!is_object($value)) {
55
+				echo $key." --> ".$value."<br>";
56
+			}
57
+		}
58
+	}
59 59
 }
Please login to merge, or discard this patch.
examples/Members/create_device_record.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
 Route4Me::setApiKey('11111111111111111111111111111111');
14 14
 
15 15
 $recordParameters = Member::fromArray(array(
16
-    'device_id'   => '546546516',
17
-    'device_type' => 'IPAD',
18
-    'format'      => 'json',
16
+	'device_id'   => '546546516',
17
+	'device_type' => 'IPAD',
18
+	'format'      => 'json',
19 19
 ));
20 20
 
21 21
 $member = new Member();
Please login to merge, or discard this patch.
examples/Members/purchase_user_license.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
 Route4Me::setApiKey('11111111111111111111111111111111');
14 14
 
15 15
 $recordParameters = Member::fromArray(array(
16
-    'member_id'         => 77777,
17
-    'session_guid'      => '454563',
18
-    'device_id'         => '54564',
19
-    'device_type'       =>'ipad',
20
-    'subscription_name' =>'IPAD_MONTHLY',
21
-    'token'             =>'4/P7q7W91a-oMsCeLvIaQm6bTrgtp7',
22
-    'payload'           =>'APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx',
23
-    'format'            =>'json'
16
+	'member_id'         => 77777,
17
+	'session_guid'      => '454563',
18
+	'device_id'         => '54564',
19
+	'device_type'       =>'ipad',
20
+	'subscription_name' =>'IPAD_MONTHLY',
21
+	'token'             =>'4/P7q7W91a-oMsCeLvIaQm6bTrgtp7',
22
+	'payload'           =>'APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx',
23
+	'format'            =>'json'
24 24
 ));
25 25
 
26 26
 $member = new Member();
Please login to merge, or discard this patch.
src/Route4Me/Address.php 1 patch
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -7,284 +7,284 @@
 block discarded – undo
7 7
 
8 8
 class Address extends Common
9 9
 {
10
-    public $route_destination_id;
11
-    public $alias;
12
-    public $member_id;
13
-    public $address;
14
-    public $addressUpdate;
15
-    public $is_depot = false;
16
-    public $lat;
17
-    public $lng;
18
-    public $route_id;
19
-    public $original_route_id;
20
-    public $optimization_problem_id;
21
-    public $sequence_no;
22
-    public $geocoded;
23
-    public $preferred_geocoding;
24
-    public $failed_geocoding;
25
-    public $geocodings = array();
26
-    public $contact_id;
27
-    public $is_visited;
28
-    public $customer_po;
29
-    public $invoice_no;
30
-    public $reference_no;
31
-    public $order_no;
32
-    public $weight;
33
-    public $cost;
34
-    public $revenue;
35
-    public $cube;
36
-    public $pieces;
37
-    public $email;
38
-    public $phone;
39
-    public $tracking_number;
40
-    public $destination_note_count;
41
-    public $drive_time_to_next_destination;
42
-    public $distance_to_next_destination;
43
-    public $generated_time_window_start;
44
-    public $generated_time_window_end;
45
-    public $time_window_start;
46
-    public $time_window_end;
47
-    public $time;
48
-    public $notes;
49
-    public $timestamp_last_visited;
50
-    public $custom_fields = array();
51
-    public $manifest = array();
10
+	public $route_destination_id;
11
+	public $alias;
12
+	public $member_id;
13
+	public $address;
14
+	public $addressUpdate;
15
+	public $is_depot = false;
16
+	public $lat;
17
+	public $lng;
18
+	public $route_id;
19
+	public $original_route_id;
20
+	public $optimization_problem_id;
21
+	public $sequence_no;
22
+	public $geocoded;
23
+	public $preferred_geocoding;
24
+	public $failed_geocoding;
25
+	public $geocodings = array();
26
+	public $contact_id;
27
+	public $is_visited;
28
+	public $customer_po;
29
+	public $invoice_no;
30
+	public $reference_no;
31
+	public $order_no;
32
+	public $weight;
33
+	public $cost;
34
+	public $revenue;
35
+	public $cube;
36
+	public $pieces;
37
+	public $email;
38
+	public $phone;
39
+	public $tracking_number;
40
+	public $destination_note_count;
41
+	public $drive_time_to_next_destination;
42
+	public $distance_to_next_destination;
43
+	public $generated_time_window_start;
44
+	public $generated_time_window_end;
45
+	public $time_window_start;
46
+	public $time_window_end;
47
+	public $time;
48
+	public $notes;
49
+	public $timestamp_last_visited;
50
+	public $custom_fields = array();
51
+	public $manifest = array();
52 52
     
53
-    public $first_name;
54
-    public $last_name;
55
-    public $is_departed;
56
-    public $timestamp_last_departed;
57
-    public $order_id;
58
-    public $priority;
59
-    public $curbside_lat;
60
-    public $curbside_lng;
61
-    public $time_window_start_2;
62
-    public $time_window_end_2;
53
+	public $first_name;
54
+	public $last_name;
55
+	public $is_departed;
56
+	public $timestamp_last_departed;
57
+	public $order_id;
58
+	public $priority;
59
+	public $curbside_lat;
60
+	public $curbside_lng;
61
+	public $time_window_start_2;
62
+	public $time_window_end_2;
63 63
 
64
-    public static function fromArray(array $params)
65
-    {
66
-        $address = new Address();
67
-        foreach ($params as $key => $value) {
68
-            if (property_exists($address, $key)) {
69
-                $address->{$key} = $value;
70
-            }
71
-        }
64
+	public static function fromArray(array $params)
65
+	{
66
+		$address = new Address();
67
+		foreach ($params as $key => $value) {
68
+			if (property_exists($address, $key)) {
69
+				$address->{$key} = $value;
70
+			}
71
+		}
72 72
         
73
-        return $address;
74
-    }
73
+		return $address;
74
+	}
75 75
 
76
-    public static function getAddress($routeId, $addressId)
77
-    {
78
-        $address = Route4Me::makeRequst(array(
79
-            'url'    => Endpoint::ADDRESS_V4,
80
-            'method' => 'GET',
81
-            'query'  => array(
82
-                'route_id'             => $routeId,
83
-                'route_destination_id' => $addressId,
84
-            )
85
-        ));
76
+	public static function getAddress($routeId, $addressId)
77
+	{
78
+		$address = Route4Me::makeRequst(array(
79
+			'url'    => Endpoint::ADDRESS_V4,
80
+			'method' => 'GET',
81
+			'query'  => array(
82
+				'route_id'             => $routeId,
83
+				'route_destination_id' => $addressId,
84
+			)
85
+		));
86 86
     
87
-        return Address::fromArray($address);
88
-    }
87
+		return Address::fromArray($address);
88
+	}
89 89
     
90
-    /*Get notes from the specified route destination
90
+	/*Get notes from the specified route destination
91 91
      * Returns an address object with notes, if an address exists, otherwise - return null.
92 92
      */
93
-    public static function GetAddressesNotes($noteParams)
94
-    {
95
-        $address = Route4Me::makeRequst(array(
96
-            'url'    => Endpoint::ADDRESS_V4,
97
-            'method' => 'GET',
98
-            'query'  => array(
99
-                'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, 
100
-                'route_destination_id' => isset($noteParams['route_destination_id']) 
101
-                                             ? $noteParams['route_destination_id'] : null,
102
-                'notes'                => 1,
103
-            )
104
-        ));
93
+	public static function GetAddressesNotes($noteParams)
94
+	{
95
+		$address = Route4Me::makeRequst(array(
96
+			'url'    => Endpoint::ADDRESS_V4,
97
+			'method' => 'GET',
98
+			'query'  => array(
99
+				'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, 
100
+				'route_destination_id' => isset($noteParams['route_destination_id']) 
101
+											 ? $noteParams['route_destination_id'] : null,
102
+				'notes'                => 1,
103
+			)
104
+		));
105 105
     
106
-        return $address;
107
-    }
106
+		return $address;
107
+	}
108 108
 
109
-    public function update()
110
-    {
111
-        $addressUpdate = Route4Me::makeRequst(array(
112
-            'url'    => Endpoint::ADDRESS_V4,
113
-            'method' => 'PUT',
114
-            'body'   => $this->toArray(),
115
-            'query'  => array(
116
-                'route_id'             => $this->route_id,
117
-                'route_destination_id' => $this->route_destination_id,
118
-            ),
119
-        ));
109
+	public function update()
110
+	{
111
+		$addressUpdate = Route4Me::makeRequst(array(
112
+			'url'    => Endpoint::ADDRESS_V4,
113
+			'method' => 'PUT',
114
+			'body'   => $this->toArray(),
115
+			'query'  => array(
116
+				'route_id'             => $this->route_id,
117
+				'route_destination_id' => $this->route_destination_id,
118
+			),
119
+		));
120 120
     
121
-        return Address::fromArray($addressUpdate);
122
-    }
121
+		return Address::fromArray($addressUpdate);
122
+	}
123 123
     
124
-    public function markAddress($params)
125
-    {
126
-        $allQueryFields = array('route_id', 'route_destination_id');
127
-        $allBodyFields = array('is_visited', 'is_departed');
124
+	public function markAddress($params)
125
+	{
126
+		$allQueryFields = array('route_id', 'route_destination_id');
127
+		$allBodyFields = array('is_visited', 'is_departed');
128 128
         
129
-        $result = Route4Me::makeRequst(array(
130
-            'url'    => Endpoint::ADDRESS_V4,
131
-            'method' => 'PUT',
132
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
133
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
134
-        ));
129
+		$result = Route4Me::makeRequst(array(
130
+			'url'    => Endpoint::ADDRESS_V4,
131
+			'method' => 'PUT',
132
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
133
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
134
+		));
135 135
     
136
-        return $result;
137
-    }
136
+		return $result;
137
+	}
138 138
     
139
-    public function markAsDeparted($params)
140
-    {
141
-        $allQueryFields = array('route_id', 'address_id', 'is_departed', 'member_id');
139
+	public function markAsDeparted($params)
140
+	{
141
+		$allQueryFields = array('route_id', 'address_id', 'is_departed', 'member_id');
142 142
         
143
-        $address = Route4Me::makeRequst(array(
144
-            'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
145
-            'method' => 'PUT',
146
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
147
-        ));
143
+		$address = Route4Me::makeRequst(array(
144
+			'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
145
+			'method' => 'PUT',
146
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
147
+		));
148 148
     
149
-        return $address;
150
-    }
149
+		return $address;
150
+	}
151 151
     
152
-    public function markAsVisited($params)
153
-    {
154
-        $allQueryFields = array('route_id', 'address_id', 'is_visited', 'member_id');
152
+	public function markAsVisited($params)
153
+	{
154
+		$allQueryFields = array('route_id', 'address_id', 'is_visited', 'member_id');
155 155
         
156
-        $address = Route4Me::makeRequst(array(
157
-            'url'    => Endpoint::UPDATE_ADDRESS_VISITED,
158
-            'method' => 'PUT',
159
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
160
-        ));
156
+		$address = Route4Me::makeRequst(array(
157
+			'url'    => Endpoint::UPDATE_ADDRESS_VISITED,
158
+			'method' => 'PUT',
159
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
160
+		));
161 161
     
162
-        return $address;
163
-    }
162
+		return $address;
163
+	}
164 164
 
165
-    public function deleteAddress()
166
-    {
167
-        $address = Route4Me::makeRequst(array(
168
-            'url'    => Endpoint::ADDRESS_V4,
169
-            'method' => 'DELETE',
170
-            'query'  => array(
171
-                'route_id'             => $this->route_id,
172
-                'route_destination_id' => $this->route_destination_id,
173
-            )
174
-        ));
165
+	public function deleteAddress()
166
+	{
167
+		$address = Route4Me::makeRequst(array(
168
+			'url'    => Endpoint::ADDRESS_V4,
169
+			'method' => 'DELETE',
170
+			'query'  => array(
171
+				'route_id'             => $this->route_id,
172
+				'route_destination_id' => $this->route_destination_id,
173
+			)
174
+		));
175 175
     
176
-        return (bool)$address['deleted'];
177
-    }
176
+		return (bool)$address['deleted'];
177
+	}
178 178
     
179
-    public function moveDestinationToRoute($params)
180
-    {
181
-        $allBodyFields = array('to_route_id', 'route_destination_id', 'after_destination_id');
179
+	public function moveDestinationToRoute($params)
180
+	{
181
+		$allBodyFields = array('to_route_id', 'route_destination_id', 'after_destination_id');
182 182
         
183
-        $result = Route4Me::makeRequst(array(
184
-            'url'    => Endpoint::MOVE_ROUTE_DESTINATION,
185
-            'method' => 'POST',
186
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
187
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
188
-        ));
183
+		$result = Route4Me::makeRequst(array(
184
+			'url'    => Endpoint::MOVE_ROUTE_DESTINATION,
185
+			'method' => 'POST',
186
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
187
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
188
+		));
189 189
 
190
-        return $result;
191
-    }
190
+		return $result;
191
+	}
192 192
     
193
-    public function AddAddressNote($params)
194
-    {
195
-        $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type');
196
-        $allBodyFields = array('strNoteContents', 'strUpdateType');
193
+	public function AddAddressNote($params)
194
+	{
195
+		$allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type');
196
+		$allBodyFields = array('strNoteContents', 'strUpdateType');
197 197
         
198
-        $result = Route4Me::makeRequst(array(
199
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
200
-            'method' => 'POST',
201
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
202
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
203
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
204
-        ));
198
+		$result = Route4Me::makeRequst(array(
199
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
200
+			'method' => 'POST',
201
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
202
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
203
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
204
+		));
205 205
 
206
-        return $result;
207
-    }
206
+		return $result;
207
+	}
208 208
 
209
-    public function AddNoteFile($params)
210
-    {
211
-        $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type', 'strUpdateType');
209
+	public function AddNoteFile($params)
210
+	{
211
+		$allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type', 'strUpdateType');
212 212
         
213
-        $result = Route4Me::makeRequst(array(
214
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
215
-            'method' => 'POST',
216
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
217
-            'body'   => array(
218
-                'strFilename'  => isset($params['strFilename']) ? Route4Me::getFileRealPath($params['strFilename']) : "" 
219
-            ),
220
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
221
-        ));
213
+		$result = Route4Me::makeRequst(array(
214
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
215
+			'method' => 'POST',
216
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
217
+			'body'   => array(
218
+				'strFilename'  => isset($params['strFilename']) ? Route4Me::getFileRealPath($params['strFilename']) : "" 
219
+			),
220
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
221
+		));
222 222
 
223
-        return $result;
224
-    }
223
+		return $result;
224
+	}
225 225
 
226
-    public function createCustomNoteType($params)
227
-    {
228
-        $allBodyFields = array('type', 'values');
226
+	public function createCustomNoteType($params)
227
+	{
228
+		$allBodyFields = array('type', 'values');
229 229
         
230
-        $result = Route4Me::makeRequst(array(
231
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
232
-            'method' => 'POST',
233
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
234
-        ));
230
+		$result = Route4Me::makeRequst(array(
231
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
232
+			'method' => 'POST',
233
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
234
+		));
235 235
 
236
-        return $result;
237
-    }
236
+		return $result;
237
+	}
238 238
     
239
-    public function removeCustomNoteType($params)
240
-    {
241
-        $result = Route4Me::makeRequst(array(
242
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
243
-            'method' => 'DELETE',
244
-            'body'   => array(
245
-                'id' => isset($params['id']) ? $params['id'] : null
246
-            )
247
-        ));
239
+	public function removeCustomNoteType($params)
240
+	{
241
+		$result = Route4Me::makeRequst(array(
242
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
243
+			'method' => 'DELETE',
244
+			'body'   => array(
245
+				'id' => isset($params['id']) ? $params['id'] : null
246
+			)
247
+		));
248 248
 
249
-        return $result;
250
-    }
249
+		return $result;
250
+	}
251 251
     
252
-    public function getAllCustomNoteTypes()
253
-    {
254
-        $result = Route4Me::makeRequst(array(
255
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
256
-            'method' => 'GET'
257
-        ));
252
+	public function getAllCustomNoteTypes()
253
+	{
254
+		$result = Route4Me::makeRequst(array(
255
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
256
+			'method' => 'GET'
257
+		));
258 258
 
259
-        return $result;
260
-    }
259
+		return $result;
260
+	}
261 261
     
262
-    public function addCustomNoteToRoute($params)
263
-    {
264
-        $customArray = array();
262
+	public function addCustomNoteToRoute($params)
263
+	{
264
+		$customArray = array();
265 265
         
266
-        foreach ($params as $key => $value) {
267
-            if (strpos($key, "custom_note_type")!==false) {
268
-                $customArray[$key] = $value;
269
-            }
270
-        }
266
+		foreach ($params as $key => $value) {
267
+			if (strpos($key, "custom_note_type")!==false) {
268
+				$customArray[$key] = $value;
269
+			}
270
+		}
271 271
         
272
-        $allQueryFields = array('route_id', 'address_id', 'format', 'dev_lat', 'dev_lng');
273
-        $allBodyFields = array('strUpdateType', 'strUpdateType', 'strNoteContents');
272
+		$allQueryFields = array('route_id', 'address_id', 'format', 'dev_lat', 'dev_lng');
273
+		$allBodyFields = array('strUpdateType', 'strUpdateType', 'strNoteContents');
274 274
         
275
-        $result = Route4Me::makeRequst(array(
276
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
277
-            'method' => 'POST',
278
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
279
-            'body'  => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray),
280
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
281
-        ));
275
+		$result = Route4Me::makeRequst(array(
276
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
277
+			'method' => 'POST',
278
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
279
+			'body'  => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray),
280
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
281
+		));
282 282
 
283
-        return $result;
284
-    }
283
+		return $result;
284
+	}
285 285
 
286
-    function getAddressId()
287
-    {
288
-        return $this->route_destination_id;
289
-    }
286
+	function getAddressId()
287
+	{
288
+		return $this->route_destination_id;
289
+	}
290 290
 }
Please login to merge, or discard this patch.
src/Route4Me/Route4Me.php 1 patch
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -7,291 +7,291 @@
 block discarded – undo
7 7
 
8 8
 class Route4Me
9 9
 {
10
-    static public $apiKey;
11
-    static public $baseUrl = Endpoint::BASE_URL;
10
+	static public $apiKey;
11
+	static public $baseUrl = Endpoint::BASE_URL;
12 12
 
13
-    public static function setApiKey($apiKey)
14
-    {
15
-        self::$apiKey = $apiKey;
16
-    }
13
+	public static function setApiKey($apiKey)
14
+	{
15
+		self::$apiKey = $apiKey;
16
+	}
17 17
 
18
-    public static function getApiKey()
19
-    {
20
-        return self::$apiKey;
21
-    }
18
+	public static function getApiKey()
19
+	{
20
+		return self::$apiKey;
21
+	}
22 22
 
23
-    public static function setBaseUrl($baseUrl)
24
-    {
25
-        self::$baseUrl = $baseUrl;
26
-    }
23
+	public static function setBaseUrl($baseUrl)
24
+	{
25
+		self::$baseUrl = $baseUrl;
26
+	}
27 27
 
28
-    public static function getBaseUrl()
29
-    {
30
-        return self::$baseUrl;
31
-    }
28
+	public static function getBaseUrl()
29
+	{
30
+		return self::$baseUrl;
31
+	}
32 32
     
33
-    public static function makeRequst($options) {
34
-        $errorHandler = new myErrorHandler();
33
+	public static function makeRequst($options) {
34
+		$errorHandler = new myErrorHandler();
35 35
 
36
-        $old_error_handler = set_error_handler(array($errorHandler, "proc_error"));
36
+		$old_error_handler = set_error_handler(array($errorHandler, "proc_error"));
37 37
 
38
-        $method = isset($options['method']) ? $options['method'] : 'GET';
39
-        $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
38
+		$method = isset($options['method']) ? $options['method'] : 'GET';
39
+		$query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
40 40
 
41
-        $body = isset($options['body']) ? $options['body'] : null;
42
-        $file = isset($options['FILE']) ? $options['FILE'] : null;
43
-        $headers = array(
44
-            "User-Agent: Route4Me php-sdk"
45
-        );
41
+		$body = isset($options['body']) ? $options['body'] : null;
42
+		$file = isset($options['FILE']) ? $options['FILE'] : null;
43
+		$headers = array(
44
+			"User-Agent: Route4Me php-sdk"
45
+		);
46 46
 
47
-        if (isset($options['HTTPHEADER'])) {
48
-            $headers[] = $options['HTTPHEADER'];
49
-        }
47
+		if (isset($options['HTTPHEADER'])) {
48
+			$headers[] = $options['HTTPHEADER'];
49
+		}
50 50
 
51
-        if (isset($options['HTTPHEADERS'])) {
52
-            foreach ($options['HTTPHEADERS'] As $header) {
53
-                $headers[] = $header;
54
-            } 
55
-        }
51
+		if (isset($options['HTTPHEADERS'])) {
52
+			foreach ($options['HTTPHEADERS'] As $header) {
53
+				$headers[] = $header;
54
+			} 
55
+		}
56 56
 
57
-        $ch = curl_init();
57
+		$ch = curl_init();
58 58
 
59
-        $url = isset($options['url']) ? $options['url'].'?'.http_build_query(array_merge(
60
-            $query, array('api_key' => self::getApiKey())
61
-        )) : "";
59
+		$url = isset($options['url']) ? $options['url'].'?'.http_build_query(array_merge(
60
+			$query, array('api_key' => self::getApiKey())
61
+		)) : "";
62 62
 
63
-        $baseUrl = self::getBaseUrl();
63
+		$baseUrl = self::getBaseUrl();
64 64
  
65
-        $curlOpts = array(
66
-            CURLOPT_URL            => $baseUrl.$url,
67
-            CURLOPT_RETURNTRANSFER => true,
68
-            CURLOPT_TIMEOUT        => 80,
69
-            CURLOPT_FOLLOWLOCATION => true,
70
-            CURLOPT_SSL_VERIFYHOST => FALSE,
71
-            CURLOPT_SSL_VERIFYPEER => FALSE,
72
-            CURLOPT_HTTPHEADER     => $headers
73
-        );
65
+		$curlOpts = array(
66
+			CURLOPT_URL            => $baseUrl.$url,
67
+			CURLOPT_RETURNTRANSFER => true,
68
+			CURLOPT_TIMEOUT        => 80,
69
+			CURLOPT_FOLLOWLOCATION => true,
70
+			CURLOPT_SSL_VERIFYHOST => FALSE,
71
+			CURLOPT_SSL_VERIFYPEER => FALSE,
72
+			CURLOPT_HTTPHEADER     => $headers
73
+		);
74 74
         
75
-        curl_setopt_array($ch, $curlOpts);
75
+		curl_setopt_array($ch, $curlOpts);
76 76
         
77
-        if ($file!=null) {
78
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
79
-            $fp=fopen($file, 'r');
80
-            curl_setopt($ch, CURLOPT_INFILE, $fp);
81
-            curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
82
-        }
77
+		if ($file!=null) {
78
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
79
+			$fp=fopen($file, 'r');
80
+			curl_setopt($ch, CURLOPT_INFILE, $fp);
81
+			curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
82
+		}
83 83
 
84
-        switch ($method) {
85
-        case 'DELETE':
86
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
87
-            break;
88
-        case 'DELETEARRAY':
89
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
90
-            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
91
-            break;
92
-        case 'PUT':
93
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
94
-            break;
95
-        case 'POST':
96
-           if (isset($body)) {
97
-                $bodyData = json_encode($body);
98
-               if (isset($options['HTTPHEADER'])) {
99
-                  if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) {
100
-                      $bodyData = $body;
101
-                  }
102
-               }
84
+		switch ($method) {
85
+		case 'DELETE':
86
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
87
+			break;
88
+		case 'DELETEARRAY':
89
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
90
+			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
91
+			break;
92
+		case 'PUT':
93
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
94
+			break;
95
+		case 'POST':
96
+		   if (isset($body)) {
97
+				$bodyData = json_encode($body);
98
+			   if (isset($options['HTTPHEADER'])) {
99
+				  if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) {
100
+					  $bodyData = $body;
101
+				  }
102
+			   }
103 103
                
104
-               curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); 
105
-            } 
106
-            break;
107
-        case 'ADD':
108
-            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
109
-        }
104
+			   curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); 
105
+			} 
106
+			break;
107
+		case 'ADD':
108
+			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
109
+		}
110 110
 
111
-        if (is_numeric(array_search($method, array('DELETE', 'PUT')))) {
112
-            if (isset($body)) {
113
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
114
-            } 
115
-        }
111
+		if (is_numeric(array_search($method, array('DELETE', 'PUT')))) {
112
+			if (isset($body)) {
113
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
114
+			} 
115
+		}
116 116
 
117
-        $result = curl_exec($ch);
117
+		$result = curl_exec($ch);
118 118
 
119
-        $isxml = FALSE;
120
-        $jxml = "";
121
-        if (strpos($result, '<?xml')>-1) {
122
-            $xml = simplexml_load_string($result);
123
-            //$jxml = json_encode($xml);
124
-            $jxml = self::object2array($xml);
125
-            $isxml = TRUE;
126
-        }
119
+		$isxml = FALSE;
120
+		$jxml = "";
121
+		if (strpos($result, '<?xml')>-1) {
122
+			$xml = simplexml_load_string($result);
123
+			//$jxml = json_encode($xml);
124
+			$jxml = self::object2array($xml);
125
+			$isxml = TRUE;
126
+		}
127 127
         
128
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
129
-        curl_close($ch);
128
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
129
+		curl_close($ch);
130 130
         
131
-        if (200==$code) {
132
-            if ($isxml) {
133
-                $json = $jxml;
134
-            } else {
135
-                $json = json_decode($result, true);
136
-            }
131
+		if (200==$code) {
132
+			if ($isxml) {
133
+				$json = $jxml;
134
+			} else {
135
+				$json = json_decode($result, true);
136
+			}
137 137
             
138
-            if (isset($json['errors'])) {
139
-                throw new ApiError(implode(', ', $json['errors']));
140
-            } else {
141
-                return $json;
142
-            }
143
-        } elseif (409==$code) {
144
-            throw new ApiError('Wrong API key');
145
-        } else {
146
-            throw new ApiError('Something wrong');
147
-        }
148
-    }
138
+			if (isset($json['errors'])) {
139
+				throw new ApiError(implode(', ', $json['errors']));
140
+			} else {
141
+				return $json;
142
+			}
143
+		} elseif (409==$code) {
144
+			throw new ApiError('Wrong API key');
145
+		} else {
146
+			throw new ApiError('Something wrong');
147
+		}
148
+	}
149 149
 
150
-    /**
151
-     * @param $object: JSON object
152
-     */
153
-    public static function object2array($object)
154
-    {
155
-        return @json_decode(@json_encode($object), 1);
156
-    }
150
+	/**
151
+	 * @param $object: JSON object
152
+	 */
153
+	public static function object2array($object)
154
+	{
155
+		return @json_decode(@json_encode($object), 1);
156
+	}
157 157
 
158 158
     
159
-    /**
160
-     * Prints on the screen main keys and values of the array 
161
-     * @param $results: object to be printed on the screen.
162
-     * @param $deepPrinting: if true, object will be printed recursively.
163
-     */
164
-    public static function simplePrint($results, $deepPrinting = null)
165
-    {
166
-        if (isset($results)) {
167
-            if (is_array($results)) {
168
-                foreach ($results as $key=>$result) {
169
-                    if (is_array($result)) {
170
-                        foreach ($result as $key1=>$result1) {
171
-                            if (is_array($result1)) {
172
-                                  if ($deepPrinting) {
173
-                                      echo "<br>$key1 ------><br>";
174
-                                      Route4Me::simplePrint($result1, true);
175
-                                      echo "------<br>";
176
-                                  } else {
177
-                                      echo $key1." --> "."Array() <br>";
178
-                                  } 
179
-                            } else {
180
-                                if (is_object($result1)) {
181
-                                    if ($deepPrinting) {
182
-                                        echo "<br>$key1 ------><br>";
183
-                                        $oarray = (array)$result1;
184
-                                        Route4Me::simplePrint($oarray, true);
185
-                                        echo "------<br>";
186
-                                    } else {
187
-                                        echo $key1." --> "."Object <br>";
188
-                                    } 
189
-                                } else {
190
-                                    if (!is_null($result1)) {
191
-                                        echo $key1." --> ".$result1."<br>"; 
192
-                                    }   
193
-                                }
194
-                            }
195
-                        }
196
-                    } else {
197
-                        if (is_object($result)) {
198
-                            if ($deepPrinting) {
199
-                                echo "<br>$key ------><br>";
200
-                                $oarray = (array)$result;
201
-                                Route4Me::simplePrint($oarray, true);
202
-                                echo "------<br>";
203
-                            } else {
204
-                                echo $key." --> "."Object <br>";
205
-                            } 
206
-                        } else {
207
-                            if (!is_null($result)) {
208
-                                echo $key." --> ".$result."<br>";
209
-                            }
210
-                        }
159
+	/**
160
+	 * Prints on the screen main keys and values of the array 
161
+	 * @param $results: object to be printed on the screen.
162
+	 * @param $deepPrinting: if true, object will be printed recursively.
163
+	 */
164
+	public static function simplePrint($results, $deepPrinting = null)
165
+	{
166
+		if (isset($results)) {
167
+			if (is_array($results)) {
168
+				foreach ($results as $key=>$result) {
169
+					if (is_array($result)) {
170
+						foreach ($result as $key1=>$result1) {
171
+							if (is_array($result1)) {
172
+								  if ($deepPrinting) {
173
+									  echo "<br>$key1 ------><br>";
174
+									  Route4Me::simplePrint($result1, true);
175
+									  echo "------<br>";
176
+								  } else {
177
+									  echo $key1." --> "."Array() <br>";
178
+								  } 
179
+							} else {
180
+								if (is_object($result1)) {
181
+									if ($deepPrinting) {
182
+										echo "<br>$key1 ------><br>";
183
+										$oarray = (array)$result1;
184
+										Route4Me::simplePrint($oarray, true);
185
+										echo "------<br>";
186
+									} else {
187
+										echo $key1." --> "."Object <br>";
188
+									} 
189
+								} else {
190
+									if (!is_null($result1)) {
191
+										echo $key1." --> ".$result1."<br>"; 
192
+									}   
193
+								}
194
+							}
195
+						}
196
+					} else {
197
+						if (is_object($result)) {
198
+							if ($deepPrinting) {
199
+								echo "<br>$key ------><br>";
200
+								$oarray = (array)$result;
201
+								Route4Me::simplePrint($oarray, true);
202
+								echo "------<br>";
203
+							} else {
204
+								echo $key." --> "."Object <br>";
205
+							} 
206
+						} else {
207
+							if (!is_null($result)) {
208
+								echo $key." --> ".$result."<br>";
209
+							}
210
+						}
211 211
                         
212
-                    }
213
-                    //echo "<br>";
214
-                }
215
-            } 
216
-        }
217
-    }
212
+					}
213
+					//echo "<br>";
214
+				}
215
+			} 
216
+		}
217
+	}
218 218
 
219
-    /**
220
-     * Generates query or body parameters.
221
-     * @param $allFields: all known fields could be used for parameters generation.
222
-     * @param $params: input parameters (array or object)
223
-     */
224
-    public static function generateRequestParameters($allFields, $params)
225
-    {
226
-        $generatedParams = array();
219
+	/**
220
+	 * Generates query or body parameters.
221
+	 * @param $allFields: all known fields could be used for parameters generation.
222
+	 * @param $params: input parameters (array or object)
223
+	 */
224
+	public static function generateRequestParameters($allFields, $params)
225
+	{
226
+		$generatedParams = array();
227 227
         
228
-        if (is_array($params)) {
229
-            foreach ($allFields as $field) {
230
-                if (isset($params[$field])) {
231
-                    $generatedParams[$field] = $params[$field];
232
-                }
233
-            }
234
-        } elseif (is_object($params)) {
235
-            foreach ($allFields as $field) {
236
-                if (isset($params->{$field})) {
237
-                    $generatedParams[$field] = $params->{$field};
238
-                }
239
-            }
240
-        }
228
+		if (is_array($params)) {
229
+			foreach ($allFields as $field) {
230
+				if (isset($params[$field])) {
231
+					$generatedParams[$field] = $params[$field];
232
+				}
233
+			}
234
+		} elseif (is_object($params)) {
235
+			foreach ($allFields as $field) {
236
+				if (isset($params->{$field})) {
237
+					$generatedParams[$field] = $params->{$field};
238
+				}
239
+			}
240
+		}
241 241
 
242
-        return $generatedParams;
243
-    }
242
+		return $generatedParams;
243
+	}
244 244
     
245
-    /**
246
-     * Returns an array of the object properties
247
-     * @param $object: An object.
248
-     * @param $exclude: array of the object parameters to be excluded from the returned array.
249
-     */
250
-    public static function getObjectProperties($object, $exclude)
251
-    {
252
-        $objectParameters = array();
245
+	/**
246
+	 * Returns an array of the object properties
247
+	 * @param $object: An object.
248
+	 * @param $exclude: array of the object parameters to be excluded from the returned array.
249
+	 */
250
+	public static function getObjectProperties($object, $exclude)
251
+	{
252
+		$objectParameters = array();
253 253
         
254
-        foreach (get_object_vars($object) as $key => $value) {
255
-            if (property_exists($object, $key)) {
256
-                if (!is_numeric(array_search($key, $exclude))) {
257
-                    array_push($objectParameters, $key);
258
-                }
259
-            }
260
-        }
254
+		foreach (get_object_vars($object) as $key => $value) {
255
+			if (property_exists($object, $key)) {
256
+				if (!is_numeric(array_search($key, $exclude))) {
257
+					array_push($objectParameters, $key);
258
+				}
259
+			}
260
+		}
261 261
         
262
-        return $objectParameters;
263
-    }
262
+		return $objectParameters;
263
+	}
264 264
     
265
-    /**
266
-     * Returns url path generated from the array of the fields and parameters.
267
-     * @param $allFields; array of the paossible fields (parameter names).
268
-     * @param $params: input parameters (array or object).
269
-     */
270
-    public static function generateUrlPath($allFields, $params)
271
-    {
272
-        $generatedPath = "";
265
+	/**
266
+	 * Returns url path generated from the array of the fields and parameters.
267
+	 * @param $allFields; array of the paossible fields (parameter names).
268
+	 * @param $params: input parameters (array or object).
269
+	 */
270
+	public static function generateUrlPath($allFields, $params)
271
+	{
272
+		$generatedPath = "";
273 273
 
274
-        if (is_array($params)) {
275
-            foreach ($allFields as $field) {
276
-                if (isset($params[$field])) {
277
-                    $generatedPath .= $params[$field].'/';
278
-                }
279
-            }
280
-        } elseif (is_object($params)) {
281
-            foreach ($allFields as $field) {
282
-                if (isset($params->{$field})) {
283
-                    $generatedPath .= $params->{$field}.'/';
284
-                }
285
-            }
286
-        }
274
+		if (is_array($params)) {
275
+			foreach ($allFields as $field) {
276
+				if (isset($params[$field])) {
277
+					$generatedPath .= $params[$field].'/';
278
+				}
279
+			}
280
+		} elseif (is_object($params)) {
281
+			foreach ($allFields as $field) {
282
+				if (isset($params->{$field})) {
283
+					$generatedPath .= $params->{$field}.'/';
284
+				}
285
+			}
286
+		}
287 287
         
288
-        return $generatedPath;
289
-    }
288
+		return $generatedPath;
289
+	}
290 290
     
291
-    public static function getFileRealPath($fileName)
292
-    {
293
-        $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName);
291
+	public static function getFileRealPath($fileName)
292
+	{
293
+		$rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName);
294 294
         
295
-        return $rpath;
296
-    }
295
+		return $rpath;
296
+	}
297 297
 }
Please login to merge, or discard this patch.