GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 5793f9...e93048 )
by Oleg
04:32
created
examples/Members/member_validate_session.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 	namespace Route4Me;
3 3
 	
4
-	$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
4
+	$vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
5 5
 
6 6
     require $vdir.'/../vendor/autoload.php';
7 7
 	
Please login to merge, or discard this patch.
examples/Members/get_users.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 	namespace Route4Me;
3 3
 	
4
-	$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
4
+	$vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
5 5
 
6 6
     require $vdir.'/../vendor/autoload.php';
7 7
 	
Please login to merge, or discard this patch.
src/Route4Me/Route4Me.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 
44 44
 		$rpath = realpath($fname);
45 45
 		
46
-		$fp=fopen(realpath($fname),"r");
46
+		$fp = fopen(realpath($fname), "r");
47 47
 		
48
-		$url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge(
49
-            array( 'api_key' => self::getApiKey()), $query)
48
+		$url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(
49
+            array('api_key' => self::getApiKey()), $query)
50 50
         );
51 51
 		
52 52
 		//self::simplePrint($body);die("");
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		//echo "code = $code <br>";
81 81
 		$json = json_decode($result, true);
82 82
 		//var_dump($json); die("");
83
-        if (200 == $code) {
83
+        if (200==$code) {
84 84
             return $json;
85 85
         } elseif (isset($json['errors'])) {
86 86
             throw new ApiError(implode(', ', $json['errors']));
@@ -102,26 +102,26 @@  discard block
 block discarded – undo
102 102
         );
103 103
         
104 104
         if (isset($options['HTTPHEADER'])) {
105
-            $headers[]=$options['HTTPHEADER'];
105
+            $headers[] = $options['HTTPHEADER'];
106 106
         }
107 107
 
108 108
 		if (isset($options['HTTPHEADERS'])) {
109
-		    foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header;
109
+		    foreach ($options['HTTPHEADERS'] As $header) $headers[] = $header;
110 110
         }
111 111
         //self::simplePrint($headers); die("");
112 112
         $ch = curl_init();
113
-        $url = $options['url'] . '?' . http_build_query(array_merge(
114
-            $query, array( 'api_key' => self::getApiKey())
113
+        $url = $options['url'].'?'.http_build_query(array_merge(
114
+            $query, array('api_key' => self::getApiKey())
115 115
         ));
116 116
 		
117 117
 		//$jfile=json_encode($body); echo $jfile; die("");
118 118
 
119 119
         //self::simplePrint($headers); die("");
120
-		$baseUrl=self::getBaseUrl();
120
+		$baseUrl = self::getBaseUrl();
121 121
 		
122
-		if (strpos($url,'move_route_destination')>0) $baseUrl='https://www.route4me.com';
122
+		if (strpos($url, 'move_route_destination')>0) $baseUrl = 'https://www.route4me.com';
123 123
         $curlOpts = arraY(
124
-            CURLOPT_URL            => $baseUrl. $url,
124
+            CURLOPT_URL            => $baseUrl.$url,
125 125
             CURLOPT_RETURNTRANSFER => true,
126 126
             CURLOPT_TIMEOUT        => 60,
127 127
             CURLOPT_FOLLOWLOCATION => true,
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
 		//echo "url=".$baseUrl.$url."<br>";die("");
134 134
         curl_setopt_array($ch, $curlOpts);
135 135
 		
136
-		if ($file !=null) {
136
+		if ($file!=null) {
137 137
 			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
138
-			$fp=fopen($file,'r');
139
-			curl_setopt($ch, CURLOPT_INFILE , $fp);
138
+			$fp = fopen($file, 'r');
139
+			curl_setopt($ch, CURLOPT_INFILE, $fp);
140 140
 			curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
141 141
 		}
142 142
 		
143
-        switch($method) {
143
+        switch ($method) {
144 144
         case 'DELETE':
145 145
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
146 146
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 			break;
166 166
         case 'POST':
167 167
 			if (isset($query)) {
168
-            	curl_setopt($ch,  CURLOPT_POSTFIELDS, json_encode($query)); 
168
+            	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); 
169 169
 			}
170 170
             
171 171
 			//echo json_encode($body); die("");
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 
180 180
         $result = curl_exec($ch);
181 181
 		//var_dump($result); die("");
182
-		$isxml=FALSE;
183
-		$jxml="";
182
+		$isxml = FALSE;
183
+		$jxml = "";
184 184
 		if (strpos($result, '<?xml')>-1)
185 185
 		{
186 186
 			$xml = simplexml_load_string($result);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			$json = $jxml;
196 196
 		} else $json = json_decode($result, true);
197 197
 		//var_dump($json); die("");
198
-        if (200 == $code) {
198
+        if (200==$code) {
199 199
             return $json;
200 200
         } elseif (isset($json['errors'])) {
201 201
             throw new ApiError(implode(', ', $json['errors']));
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		
227 227
 		curl_setopt_array($ch, $curlOpts);
228 228
 		
229
-        switch($method) {
229
+        switch ($method) {
230 230
         case 'DELETE':
231 231
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
232 232
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 
265 265
 		$result = curl_exec($ch);
266 266
         
267
-		$isxml=FALSE;
268
-		$jxml="";
267
+		$isxml = FALSE;
268
+		$jxml = "";
269 269
 		if (strpos($result, '<?xml')>-1)
270 270
 		{
271 271
 			$xml = simplexml_load_string($result);
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		} else $json = json_decode($result, true);
282 282
 		
283 283
 		
284
-        if (200 == $code) {
284
+        if (200==$code) {
285 285
             return $json;
286 286
         } elseif (isset($json['errors'])) {
287 287
             throw new ApiError(implode(', ', $json['errors']));
Please login to merge, or discard this patch.
examples/GarageDoorOpener/myq_login.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-	$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
2
+	$vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
3 3
     require $vdir.'/../vendor/autoload.php';
4 4
 	
5 5
 	use Route4Me\MyQ;
Please login to merge, or discard this patch.
src/Route4Me/Member.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		public $config_key;
65 65
 		public $config_value;
66 66
 		
67
-		public function __construct () {  }
67
+		public function __construct() {  }
68 68
 		
69 69
 		public static function fromArray(array $params) {
70
-			$member= new Member();
71
-	        foreach($params as $key => $value) {
70
+			$member = new Member();
71
+	        foreach ($params as $key => $value) {
72 72
 	            if (property_exists($member, $key)) {
73 73
 	                $member->{$key} = $value;
74 74
 	            }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	            'url'    => self::$apiUrlDevice,
120 120
 	            'method' => 'POST',
121 121
 	            'body'  => array(
122
-					'device_id' => 	isset($body->device_id) ? $body->device_id: null,
122
+					'device_id' => 	isset($body->device_id) ? $body->device_id : null,
123 123
 	                'device_type' => isset($body->device_type) ? $body->device_type : null,
124 124
 	                'format' => isset($body->format) ? $body->format : null
125 125
 				)
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	            'url'    => self::$apiUrl,
135 135
 	            'method' => 'POST',
136 136
 	            'body'  => array(
137
-					'HIDE_ROUTED_ADDRESSES' => 	isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES: null,
137
+					'HIDE_ROUTED_ADDRESSES' => 	isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES : null,
138 138
 	                'member_phone' => isset($body->member_phone) ? $body->member_phone : null,
139 139
 	                'member_zipcode' => isset($body->member_zipcode) ? $body->member_zipcode : null,
140 140
 	                'route_count' => isset($body->route_count) ? $body->route_count : null,
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	            'url'    => self::$apiUrl,
161 161
 	            'method' => 'PUT',
162 162
 	            'body'  => array(
163
-					'member_id' => 	isset($body->member_id) ? $body->member_id: null,
163
+					'member_id' => 	isset($body->member_id) ? $body->member_id : null,
164 164
 	                'member_phone' => isset($body->member_phone) ? $body->member_phone : null,
165
-	                'HIDE_ROUTED_ADDRESSES' => 	isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES: null,
165
+	                'HIDE_ROUTED_ADDRESSES' => 	isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES : null,
166 166
 	                'member_zipcode' => isset($body->member_zipcode) ? $body->member_zipcode : null,
167 167
 	                'route_count' => isset($body->route_count) ? $body->route_count : null,
168 168
 	                'member_email' => isset($body->member_email) ? $body->member_email : null,
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	            'url'    => self::$apiUrl,
188 188
 	            'method' => 'DELETE',
189 189
 	            'body'  => array(
190
-					'member_id' => 	isset($body->member_id) ? $body->member_id: null
190
+					'member_id' => 	isset($body->member_id) ? $body->member_id : null
191 191
 				)
192 192
 
193 193
 			));
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 	            'url'    => self::$apiUrlRegistr,
201 201
 	            'method' => 'POST',
202 202
 	            'body'  => array(
203
-					'strEmail' => 	isset($body->strEmail) ? $body->strEmail: null,
203
+					'strEmail' => 	isset($body->strEmail) ? $body->strEmail : null,
204 204
 	                'strPassword_1' => isset($body->strPassword_1) ? $body->strPassword_1 : null,
205 205
 	                'strPassword_2' => isset($body->strPassword_2) ? $body->strPassword_2 : null,
206
-	                'strFirstName' => 	isset($body->strFirstName) ? $body->strFirstName: null,
207
-	                'strLastName' => 	isset($body->strLastName) ? $body->strLastName: null,
208
-	                'strIndustry' => 	isset($body->strIndustry) ? $body->strIndustry: null,
209
-	                'chkTerms' => 	isset($body->chkTerms) ? $body->chkTerms: null,
210
-	                'plan' => 	isset($body->plan) ? $body->plan: null,
211
-	                'strSubAccountType' =>  isset($body->strSubAccountType) ? $body->strSubAccountType: null,
212
-	                'blDisableMarketing' => isset($body->blDisableMarketing) ? $body->blDisableMarketing: false,
213
-	                'blDisableAccountActivationEmail' => isset($body->blDisableAccountActivationEmail) ? $body->blDisableAccountActivationEmail: false
206
+	                'strFirstName' => 	isset($body->strFirstName) ? $body->strFirstName : null,
207
+	                'strLastName' => 	isset($body->strLastName) ? $body->strLastName : null,
208
+	                'strIndustry' => 	isset($body->strIndustry) ? $body->strIndustry : null,
209
+	                'chkTerms' => 	isset($body->chkTerms) ? $body->chkTerms : null,
210
+	                'plan' => 	isset($body->plan) ? $body->plan : null,
211
+	                'strSubAccountType' =>  isset($body->strSubAccountType) ? $body->strSubAccountType : null,
212
+	                'blDisableMarketing' => isset($body->blDisableMarketing) ? $body->blDisableMarketing : false,
213
+	                'blDisableAccountActivationEmail' => isset($body->blDisableAccountActivationEmail) ? $body->blDisableAccountActivationEmail : false
214 214
 				)
215 215
 			));
216 216
 			return $response;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	            'url'    => self::$apiUrlSessValid,
223 223
 	            'method' => 'GET',
224 224
 	            'query'  => array(
225
-					'session_guid' => 	isset($params->session_guid) ? $params->session_guid: null,
225
+					'session_guid' => 	isset($params->session_guid) ? $params->session_guid : null,
226 226
 	                'member_id' => isset($params->member_id) ? $params->member_id : null,
227 227
 	                'format' => isset($params->format) ? $params->format : null
228 228
 				)
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	            'url'    => self::$apiUrlAuthen,
237 237
 	            'method' => 'POST',
238 238
 	            'body'  => array(
239
-					'strEmail' => 	isset($body->strEmail) ? $body->strEmail: null,
239
+					'strEmail' => 	isset($body->strEmail) ? $body->strEmail : null,
240 240
 	                'strPassword' => isset($body->strPassword) ? $body->strPassword : null,
241 241
 	                'format' => isset($body->format) ? $body->format : null
242 242
 				)
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	            'url'    => self::$apiUrlWebinar,
252 252
 	            'method' => 'POST',
253 253
 	            'body'  => array(
254
-					'email_address' => 	isset($body->email_address) ? $body->email_address: null,
254
+					'email_address' => 	isset($body->email_address) ? $body->email_address : null,
255 255
 	                'first_name' => isset($body->first_name) ? $body->first_name : null,
256 256
 	                'last_name' => isset($body->last_name) ? $body->last_name : null,
257 257
 	                'phone_number' => isset($body->phone_number) ? $body->phone_number : null,
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	            'url'    => self::$apiUrlLicense,
271 271
 	            'method' => 'POST',
272 272
 	            'body'  => array(
273
-					'member_id' => 	isset($body->member_id) ? $body->member_id: null,
273
+					'member_id' => 	isset($body->member_id) ? $body->member_id : null,
274 274
 	                'session_guid' => isset($body->session_guid) ? $body->session_guid : null,
275 275
 	                'device_id' => isset($body->device_id) ? $body->device_id : null,
276 276
 	                'device_type' => isset($body->device_type) ? $body->device_type : null,
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	            'url'    => self::$apiMemberConfig,
291 291
 	            'method' => 'POST',
292 292
 	            'body'  => array(
293
-					'config_key' => 	isset($body->config_key) ? $body->config_key: null,
293
+					'config_key' => 	isset($body->config_key) ? $body->config_key : null,
294 294
 	                'config_value' => isset($body->config_value) ? $body->config_value : null
295 295
 				)
296 296
 			));
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	            'url'    => self::$apiMemberConfig,
304 304
 	            'method' => 'DELETE',
305 305
 	            'body'  => array(
306
-					'config_key' => 	isset($body->config_key) ? $body->config_key: null
306
+					'config_key' => 	isset($body->config_key) ? $body->config_key : null
307 307
 				)
308 308
 			));
309 309
 			return $response;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	            'url'    => self::$apiMemberConfig,
316 316
 	            'method' => 'GET',
317 317
 	            'query'  => array(
318
-					'config_key' => 	isset($body->config_key) ? $body->config_key: null
318
+					'config_key' => 	isset($body->config_key) ? $body->config_key : null
319 319
 				)
320 320
 			));
321 321
 			return $response;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	            'url'    => self::$apiMemberConfig,
328 328
 	            'method' => 'PUT',
329 329
 	            'body'  => array(
330
-					'config_key' => 	isset($body->config_key) ? $body->config_key: null,
330
+					'config_key' => 	isset($body->config_key) ? $body->config_key : null,
331 331
 	                'config_value' => isset($body->config_value) ? $body->config_value : null
332 332
 				)
333 333
 			));
Please login to merge, or discard this patch.
src/Route4Me/OptimizationProblem.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
             'url'    => self::$apiUrl,
70 70
             'method' => 'POST',
71 71
             'query'  => array(
72
-                'directions'             => isset($params->directions) ? $params->directions: null, 
73
-                'format'                 => isset($params->format) ? $params->format: null,
74
-                'route_path_output'      => isset($params->route_path_output) ? $params->route_path_output: null,
75
-                'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url: null
72
+                'directions'             => isset($params->directions) ? $params->directions : null, 
73
+                'format'                 => isset($params->format) ? $params->format : null,
74
+                'route_path_output'      => isset($params->route_path_output) ? $params->route_path_output : null,
75
+                'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null
76 76
             ),
77 77
             'body'   => array(
78 78
                 'addresses'  => $params->getAddressesArray(),
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
         if (isset($optimize['optimizations'])) {
103 103
             $problems = array();
104
-            foreach($optimize['optimizations'] as $problem) {
104
+            foreach ($optimize['optimizations'] as $problem) {
105 105
                 $problems[] = OptimizationProblem::fromArray($problem);
106 106
             }
107 107
             return $problems;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         return $this->routes;
145 145
     }
146 146
 	
147
-	public function getRandomOptimizationId($offset,$limit)
147
+	public function getRandomOptimizationId($offset, $limit)
148 148
 	{
149 149
 		$query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
150 150
         $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
         ));
157 157
 		
158 158
 		$optimizations = array();
159
-            foreach($json as $optimization) {
159
+            foreach ($json as $optimization) {
160 160
 				if (gettype($optimization)!="array") continue;
161 161
 				foreach ($optimization as $otp1) {
162 162
 					$optimizations[] = $otp1;
163 163
 				}
164 164
             }
165 165
 			
166
-			$num=rand(0,sizeof($optimizations)-1);
166
+			$num = rand(0, sizeof($optimizations) - 1);
167 167
 			//echo "num=$num.<br>".sizeof($optimizations)."<br>";
168
-			$rOptimization=$optimizations[$num];
168
+			$rOptimization = $optimizations[$num];
169 169
 			return $rOptimization;
170 170
 	}
171 171
 	
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	{
174 174
 		if ($opt_id==null) return null;
175 175
 		
176
-		$params = array( "optimization_problem_id" => $opt_id );
176
+		$params = array("optimization_problem_id" => $opt_id);
177 177
 		
178 178
 		$optimization = (array)$this->get($params);
179 179
 		
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 	{
188 188
 		$addresses = (array)$this->getAddresses($opt_id);
189 189
 		
190
-		if ($addresses == null) {
190
+		if ($addresses==null) {
191 191
 			echo "There are no addresses in this optimization!.. Try again.";
192 192
 			return null;
193 193
 		}
194 194
 		
195
-		$num=rand(0,sizeof($addresses)-1);
196
-		$rAddress=$addresses[$num];
195
+		$num = rand(0, sizeof($addresses) - 1);
196
+		$rAddress = $addresses[$num];
197 197
 		
198 198
 		return $rAddress;
199 199
 	}
Please login to merge, or discard this patch.
src/Route4Me/AddressBookLocation.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 		//public $offset;
33 33
 		//public $limit;
34 34
 		
35
-		public function __construct () {  }
35
+		public function __construct() {  }
36 36
 		
37 37
 		public static function fromArray(array $params) {
38 38
 			$addressbooklocation = new AddressBookLocation();
39
-	        foreach($params as $key => $value) {
39
+	        foreach ($params as $key => $value) {
40 40
 	            if (property_exists($addressbooklocation, $key)) {
41 41
 	                $addressbooklocation->{$key} = $value;
42 42
 	            }
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 		
62 62
 		public static function searchRoutedLocation($params)
63 63
 	    {
64
-	    	$result= Route4Me::makeRequst(array(
64
+	    	$result = Route4Me::makeRequst(array(
65 65
 	            'url'    => self::$apiUrl,
66 66
 	            'method' => 'GET',
67 67
 	            'query'  => array(
68
-	                'display' => isset($params['display']) ? $params['display']: null,
69
-	                'query' => isset($params['query']) ? $params['query']: null,
70
-	                'fields' => isset($params['fields']) ? $params['fields']: null,
71
-	                'limit' => isset($params['limit']) ? $params['limit']: null,
68
+	                'display' => isset($params['display']) ? $params['display'] : null,
69
+	                'query' => isset($params['query']) ? $params['query'] : null,
70
+	                'fields' => isset($params['fields']) ? $params['fields'] : null,
71
+	                'limit' => isset($params['limit']) ? $params['limit'] : null,
72 72
 	                'offset' => isset($params['offset']) ? $params['offset'] : null,
73 73
 	            )
74 74
 	        ));
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	            'url'    => self::$apiUrl,
83 83
 	            'method' => 'GET',
84 84
 	            'query'  => array(
85
-	                'limit' => isset($params->limit) ? $params->limit: null,
85
+	                'limit' => isset($params->limit) ? $params->limit : null,
86 86
 	                'offset' => isset($params->offset) ? $params->offset : null,
87 87
 	            )
88 88
 	        ));
@@ -109,42 +109,42 @@  discard block
 block discarded – undo
109 109
 	            'url'    => self::$apiUrl,
110 110
 	            'method' => 'POST',
111 111
 	            'body'  => array(
112
-	            	'address_1' => 	isset($params->address_1) ? $params->address_1: null,
113
-	            	'address_2' =>    isset($params->address_2) ? $params->address_2: null,
114
-	            	'address_alias' =>    isset($params->address_alias) ? $params->address_alias: null,
112
+	            	'address_1' => 	isset($params->address_1) ? $params->address_1 : null,
113
+	            	'address_2' =>    isset($params->address_2) ? $params->address_2 : null,
114
+	            	'address_alias' =>    isset($params->address_alias) ? $params->address_alias : null,
115 115
 	                'first_name' => isset($params->first_name) ? $params->first_name : null,
116 116
 	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
117 117
 	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
118 118
 	                'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null,
119 119
                     'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null,
120
-	                'address_phone_number' =>    isset($params->address_phone_number) ? $params->address_phone_number: null,
121
-	                'address_group' =>    isset($params->address_group) ? $params->address_group: null,
122
-	                'first_name' =>    isset($params->first_name) ? $params->first_name: null,
123
-	                'last_name' =>    isset($params->last_name) ? $params->last_name: null,
124
-                    'local_time_window_start' =>    isset($params->local_time_window_start) ? $params->local_time_window_start: null,
125
-                    'local_time_window_end' =>    isset($params->local_time_window_end) ? $params->local_time_window_end: null,
126
-                    'local_time_window_start_2' =>    isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null,
127
-                    'local_time_window_end_2' =>    isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null,
128
-	                'address_email' =>    isset($params->address_email) ? $params->address_email: null,
129
-	                'address_city' =>    isset($params->address_city) ? $params->address_city: null,
130
-	                'address_state_id' =>    isset($params->address_state_id) ? $params->address_state_id: null,
131
-	                'address_country_id' =>    isset($params->address_country_id) ? $params->address_country_id: null,
132
-	                'address_zip' =>    isset($params->address_zip) ? $params->address_zip: null,
133
-	                'address_custom_data' =>    isset($params->address_custom_data) ? $params->address_custom_data: null,
134
-	                'schedule' =>    isset($params->schedule) ? $params->schedule: null,
135
-	                'schedule_blacklist' =>    isset($params->schedule_blacklist) ? $params->schedule_blacklist: null,
136
-	                'service_time' =>    isset($params->service_time) ? $params->service_time: null,
137
-	                'local_timezone_string' =>    isset($params->local_timezone_string) ? $params->local_timezone_string: null,
138
-	                'color' =>    isset($params->color) ? $params->color: null,
139
-	                'address_icon' =>    isset($params->address_icon) ? $params->address_icon: null,
140
-	                'address_stop_type' =>    isset($params->address_stop_type) ? $params->address_stop_type: null,
141
-	                'address_cube' =>    isset($params->address_cube) ? $params->address_cube: null,
142
-	                'address_pieces' =>    isset($params->address_pieces) ? $params->address_pieces: null,
143
-	                'address_reference_no' =>    isset($params->address_reference_no) ? $params->address_reference_no: null,
144
-	                'address_revenue' =>    isset($params->address_revenue) ? $params->address_revenue: null,
145
-	                'address_weight' =>    isset($params->address_weight) ? $params->address_weight: null,
146
-	                'address_priority' =>    isset($params->address_priority) ? $params->address_priority: null,
147
-	                'address_customer_po' =>    isset($params->address_customer_po) ? $params->address_customer_po: null,
120
+	                'address_phone_number' =>    isset($params->address_phone_number) ? $params->address_phone_number : null,
121
+	                'address_group' =>    isset($params->address_group) ? $params->address_group : null,
122
+	                'first_name' =>    isset($params->first_name) ? $params->first_name : null,
123
+	                'last_name' =>    isset($params->last_name) ? $params->last_name : null,
124
+                    'local_time_window_start' =>    isset($params->local_time_window_start) ? $params->local_time_window_start : null,
125
+                    'local_time_window_end' =>    isset($params->local_time_window_end) ? $params->local_time_window_end : null,
126
+                    'local_time_window_start_2' =>    isset($params->local_time_window_start_2) ? $params->local_time_window_start_2 : null,
127
+                    'local_time_window_end_2' =>    isset($params->local_time_window_end_2) ? $params->local_time_window_end_2 : null,
128
+	                'address_email' =>    isset($params->address_email) ? $params->address_email : null,
129
+	                'address_city' =>    isset($params->address_city) ? $params->address_city : null,
130
+	                'address_state_id' =>    isset($params->address_state_id) ? $params->address_state_id : null,
131
+	                'address_country_id' =>    isset($params->address_country_id) ? $params->address_country_id : null,
132
+	                'address_zip' =>    isset($params->address_zip) ? $params->address_zip : null,
133
+	                'address_custom_data' =>    isset($params->address_custom_data) ? $params->address_custom_data : null,
134
+	                'schedule' =>    isset($params->schedule) ? $params->schedule : null,
135
+	                'schedule_blacklist' =>    isset($params->schedule_blacklist) ? $params->schedule_blacklist : null,
136
+	                'service_time' =>    isset($params->service_time) ? $params->service_time : null,
137
+	                'local_timezone_string' =>    isset($params->local_timezone_string) ? $params->local_timezone_string : null,
138
+	                'color' =>    isset($params->color) ? $params->color : null,
139
+	                'address_icon' =>    isset($params->address_icon) ? $params->address_icon : null,
140
+	                'address_stop_type' =>    isset($params->address_stop_type) ? $params->address_stop_type : null,
141
+	                'address_cube' =>    isset($params->address_cube) ? $params->address_cube : null,
142
+	                'address_pieces' =>    isset($params->address_pieces) ? $params->address_pieces : null,
143
+	                'address_reference_no' =>    isset($params->address_reference_no) ? $params->address_reference_no : null,
144
+	                'address_revenue' =>    isset($params->address_revenue) ? $params->address_revenue : null,
145
+	                'address_weight' =>    isset($params->address_weight) ? $params->address_weight : null,
146
+	                'address_priority' =>    isset($params->address_priority) ? $params->address_priority : null,
147
+	                'address_customer_po' =>    isset($params->address_customer_po) ? $params->address_customer_po : null,
148 148
 	            )
149 149
 	        ));
150 150
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	            'method' => 'ADD',
185 185
 	            'query'  => array(
186 186
 	                'first_name' => isset($params->first_name) ? $params->first_name : null,
187
-	                'address_1' => isset($params->address_1) ? $params->address_1: null,
187
+	                'address_1' => isset($params->address_1) ? $params->address_1 : null,
188 188
 	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
189 189
 	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
190 190
 	            )
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         
196 196
         public static function validateScheduleMode($scheduleMode)
197 197
         {
198
-            $schedMmodes=array("daily","weekly","monthly","annually");
198
+            $schedMmodes = array("daily", "weekly", "monthly", "annually");
199 199
             
200 200
             if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE;
201 201
         }
202 202
         
203 203
         public static function validateScheduleEnable($scheduleEnabled)
204 204
         {
205
-            $schedEnambles=array(TRUE,FALSE);
205
+            $schedEnambles = array(TRUE, FALSE);
206 206
             
207 207
             if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE;
208 208
         }
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
             
219 219
             if (sizeof($weekdays)<1) return FALSE;
220 220
             
221
-            $isValid=TRUE;
221
+            $isValid = TRUE;
222 222
             
223
-            for ($i=0; $i < sizeof($weekdays); $i++) { 
223
+            for ($i = 0; $i<sizeof($weekdays); $i++) { 
224 224
                 if (is_numeric($weekdays[$i])) {
225
-                    $wday=intval($weekdays[$i]);
226
-                    if ($wday<1 || $wday>7) $isValid=FALSE;
225
+                    $wday = intval($weekdays[$i]);
226
+                    if ($wday<1 || $wday>7) $isValid = FALSE;
227 227
                 }
228
-                else $isValid=FALSE;
228
+                else $isValid = FALSE;
229 229
             }
230 230
             //echo $scheduleWeekDays.' --- '. $isValid."<br>";
231 231
             return $isValid;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         
234 234
         public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
235 235
         {
236
-            $schedMonthlyMmodes=array("dates","nth");
236
+            $schedMonthlyMmodes = array("dates", "nth");
237 237
             
238 238
             if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE;
239 239
         }
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
             
245 245
             if (sizeof($monthlyDates)<1) return FALSE;
246 246
             
247
-            $isValid=TRUE;
247
+            $isValid = TRUE;
248 248
             
249
-            for ($i=0; $i < sizeof($monthlyDates); $i++) { 
249
+            for ($i = 0; $i<sizeof($monthlyDates); $i++) { 
250 250
                 if (is_numeric($monthlyDates[$i])) {
251
-                    $mday=intval($monthlyDates[$i]);
252
-                    if ($mday<1 || $mday>31) $isValid=FALSE;
251
+                    $mday = intval($monthlyDates[$i]);
252
+                    if ($mday<1 || $mday>31) $isValid = FALSE;
253 253
                 }
254
-                else $isValid=FALSE;
254
+                else $isValid = FALSE;
255 255
             }
256 256
             //echo $scheduleMonthlyDates.' --- '. $isValid."<br>";
257 257
             return $isValid;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         {
262 262
             if (!is_numeric($scheduleNthN)) return FALSE;
263 263
             
264
-            $schedNthNs=array(1,2,3,4,5,-1);
264
+            $schedNthNs = array(1, 2, 3, 4, 5, -1);
265 265
             if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE;
266 266
         }
267 267
         
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
         {
270 270
             if (!is_numeric($scheduleNthWhat)) return FALSE;
271 271
             
272
-            $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
272
+            $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
273 273
             if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE;
274 274
         }
275 275
 	}
Please login to merge, or discard this patch.
examples/Optimizations/hybridOptimization.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Route4Me;
3 3
 
4
-$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
4
+$vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
5 5
 
6 6
 require $vdir.'/../vendor/autoload.php';
7 7
 
@@ -17,113 +17,113 @@  discard block
 block discarded – undo
17 17
 
18 18
 Route4Me::setApiKey('11111111111111111111111111111111');
19 19
 
20
-$source_file="addresses_1000.csv";
20
+$source_file = "addresses_1000.csv";
21 21
 $max_line_length = 512;
22
-$delemietr=',';
22
+$delemietr = ',';
23 23
 
24 24
 
25 25
 /* Add Address Book Locations with schedules */
26 26
 
27
-if (($handle = fopen("$source_file", "r")) !== FALSE) {
27
+if (($handle = fopen("$source_file", "r"))!==FALSE) {
28 28
         $columns = fgetcsv($handle, $max_line_length, $delemietr);
29 29
         if (!$columns) {
30 30
             $error['message'] = 'Empty';
31 31
              return ($error);
32 32
         }
33 33
         
34
-        $iRow=1;
34
+        $iRow = 1;
35 35
         
36
-        while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) {
36
+        while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) {
37 37
             //if ($iRow==1) {$iRow++; continue;}
38 38
             
39
-            if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) { // ignore blank lines
39
+            if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { // ignore blank lines
40 40
                     //$data1 = $rows[0].", ".$rows[1].", ".$rows[3];
41 41
                     
42
-                    $schedule="";
43
-                    $mode="";
42
+                    $schedule = "";
43
+                    $mode = "";
44 44
                     
45 45
                     if (isset($rows[8])) {
46 46
                         if (AddressBookLocation::validateScheduleMode($rows[8])) {
47
-                            $schedule='"mode":"'.$rows[8].'",'; 
48
-                            $mode=$rows[8];
47
+                            $schedule = '"mode":"'.$rows[8].'",'; 
48
+                            $mode = $rows[8];
49 49
                         }
50
-                        else {echo "$iRow --> Wrong schedule mode parameter <br>"; $schedule="";}
50
+                        else {echo "$iRow --> Wrong schedule mode parameter <br>"; $schedule = ""; }
51 51
                     }
52
-                    else {echo "$iRow --> The schedule mode parameter is not set <br>"; $schedule="";}
52
+                    else {echo "$iRow --> The schedule mode parameter is not set <br>"; $schedule = ""; }
53 53
                     
54
-                    if ($schedule=="") {$iRow++; continue;}
54
+                    if ($schedule=="") {$iRow++; continue; }
55 55
                     
56 56
                     if (isset($rows[9])) {
57 57
                         if (AddressBookLocation::validateScheduleEnable($rows[9])) { 
58
-                            $schedule.='"enabled":'.$rows[9].',';
58
+                            $schedule .= '"enabled":'.$rows[9].',';
59 59
                         }
60
-                        else {echo "$iRow --> The schedule enabled parameter is not set <br>"; $schedule="";}
60
+                        else {echo "$iRow --> The schedule enabled parameter is not set <br>"; $schedule = ""; }
61 61
                     }
62 62
                     
63
-                    if ($schedule=="") {$iRow++; continue;}
63
+                    if ($schedule=="") {$iRow++; continue; }
64 64
                     
65 65
                     if (isset($rows[10])) {
66 66
                         if (AddressBookLocation::validateScheduleEvery($rows[10])) {
67
-                            $schedule.='"'.$mode.'":{'.'"every":'.$rows[10].','; 
67
+                            $schedule .= '"'.$mode.'":{'.'"every":'.$rows[10].','; 
68 68
                             if ($mode=='daily') {
69
-                                $schedule=trim($schedule,',');
70
-                                $schedule.='}';
69
+                                $schedule = trim($schedule, ',');
70
+                                $schedule .= '}';
71 71
                             }
72 72
                         }
73
-                        else {echo "$iRow --> The parameter sched_every is not set <br>"; $schedule=""; }
73
+                        else {echo "$iRow --> The parameter sched_every is not set <br>"; $schedule = ""; }
74 74
                     }
75 75
                     
76
-                    if ($schedule=="") {$iRow++; continue;}
76
+                    if ($schedule=="") {$iRow++; continue; }
77 77
                     
78 78
                     if ($mode!='daily') {
79 79
                         switch ($mode) {
80 80
                             case 'weekly':
81 81
                                 if (isset($rows[11])) {
82 82
                                     if (AddressBookLocation::validateScheduleWeekDays($rows[11])) {
83
-                                         $schedule.='"weekdays":['.$rows[11].']}';
83
+                                         $schedule .= '"weekdays":['.$rows[11].']}';
84 84
                                     }
85
-                                    else {echo "$iRow --> Wrong weekdays <br>";$schedule="";}
85
+                                    else {echo "$iRow --> Wrong weekdays <br>"; $schedule = ""; }
86 86
                                 }
87
-                                else {echo "$iRow --> The parameters sched_weekdays is not set <br>"; $schedule="";}
87
+                                else {echo "$iRow --> The parameters sched_weekdays is not set <br>"; $schedule = ""; }
88 88
                                 break;
89 89
                             case 'monthly':
90
-                                $monthlyMode="";
90
+                                $monthlyMode = "";
91 91
                                 if (isset($rows[12])) {
92 92
                                     if (AddressBookLocation::validateScheduleMonthlyMode($rows[12])) {
93
-                                         $monthlyMode=$rows[12];
94
-                                         $schedule.='"mode": "'.$rows[12].'",';
93
+                                         $monthlyMode = $rows[12];
94
+                                         $schedule .= '"mode": "'.$rows[12].'",';
95 95
                                     }
96
-                                    else {echo "$iRow --> Wrong monthly mode <br>"; $schedule="";}
96
+                                    else {echo "$iRow --> Wrong monthly mode <br>"; $schedule = ""; }
97 97
                                 }
98
-                                else {echo "$iRow --> The parameter sched_monthly_mode is not set <br>"; $schedule="";}
98
+                                else {echo "$iRow --> The parameter sched_monthly_mode is not set <br>"; $schedule = ""; }
99 99
                                 
100 100
                                 if ($monthlyMode!="") {
101 101
                                     switch ($monthlyMode) {
102 102
                                         case 'dates':
103 103
                                             if (isset($rows[13])) {
104 104
                                                 if (AddressBookLocation::validateScheduleMonthlyDates($rows[13])) {
105
-                                                     $schedule.='"dates":['.$rows[13].']}';
105
+                                                     $schedule .= '"dates":['.$rows[13].']}';
106 106
                                                 }
107
-                                                else {echo "$iRow --> Wrong monthly dates <br>"; $schedule="";}
107
+                                                else {echo "$iRow --> Wrong monthly dates <br>"; $schedule = ""; }
108 108
                                             }
109 109
                                             break;
110 110
                                         case 'nth':
111 111
                                             if (isset($rows[16])) {
112 112
                                                 if (AddressBookLocation::validateScheduleNthN($rows[16])) {
113
-                                                     $schedule.='"nth":{"n":'.$rows[16].',';
113
+                                                     $schedule .= '"nth":{"n":'.$rows[16].',';
114 114
                                                 }
115
-                                                else {echo "$iRow --> Wrong parameter sched_nth_n <br>"; $schedule="";}
115
+                                                else {echo "$iRow --> Wrong parameter sched_nth_n <br>"; $schedule = ""; }
116 116
                                             }
117
-                                            else {echo "$iRow --> The parameter sched_nth_n is not set <br>"; $schedule="";}
117
+                                            else {echo "$iRow --> The parameter sched_nth_n is not set <br>"; $schedule = ""; }
118 118
                                             
119 119
                                             if ($schedule!="") {
120 120
                                                 if (isset($rows[17])) {
121 121
                                                     if (AddressBookLocation::validateScheduleNthWhat($rows[17])) {
122
-                                                         $schedule.='"what":'.$rows[17].'}}';
122
+                                                         $schedule .= '"what":'.$rows[17].'}}';
123 123
                                                     }
124
-                                                    else {echo "$iRow --> Wrong parameter sched_nth_what <br>"; $schedule="";}
124
+                                                    else {echo "$iRow --> Wrong parameter sched_nth_what <br>"; $schedule = ""; }
125 125
                                                 }
126
-                                                else {echo "$iRow --> The parameter sched_nth_what is not set <br>"; $schedule="";}
126
+                                                else {echo "$iRow --> The parameter sched_nth_what is not set <br>"; $schedule = ""; }
127 127
                                             }
128 128
                                             
129 129
                                             break;
@@ -137,18 +137,18 @@  discard block
 block discarded – undo
137 137
                         
138 138
                     }
139 139
                     
140
-                    if ($schedule=="") {$iRow++; continue;}
140
+                    if ($schedule=="") {$iRow++; continue; }
141 141
                     
142
-                    $schedule=strtolower($schedule);
142
+                    $schedule = strtolower($schedule);
143 143
                     
144
-                    $schedule='[{'.$schedule.'}]';
144
+                    $schedule = '[{'.$schedule.'}]';
145 145
 
146 146
                     //echo "$iRow --> ".$schedule."<br>";
147
-                    $oSchedule= json_decode($schedule,TRUE);
147
+                    $oSchedule = json_decode($schedule, TRUE);
148 148
                     
149 149
                     //echo "<br>"; var_dump($oSchedule); echo "<br>";
150 150
                     
151
-                    $AdressBookLocationParameters=AddressBookLocation::fromArray(array(
151
+                    $AdressBookLocationParameters = AddressBookLocation::fromArray(array(
152 152
                         "cached_lat"    => $rows[0],
153 153
                         "cached_lng"    => $rows[1],
154 154
                         "address_alias"     => $rows[2],
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
                         "schedule" => isset($oSchedule) ? $oSchedule : null,
161 161
                     ));
162 162
                     
163
-                    $abContacts=new AddressBookLocation();
163
+                    $abContacts = new AddressBookLocation();
164 164
     
165
-                    $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
165
+                    $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
166 166
                     
167 167
                     echo "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly <br>"; //temporarry
168 168
               }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
 /* Get Hybrid Optimization */
175 175
 
176
-    $ep = time()+604800;
176
+    $ep = time() + 604800;
177 177
     $sched_date = date("Y-m-d", $ep);
178 178
 
179 179
     $hybridParams = array(
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             /* Add depots to the Hybrid Optimization */
195 195
             $depotfile = "depots.csv";
196 196
             
197
-            if (($handle = fopen("$depotfile", "r")) !== FALSE) {
197
+            if (($handle = fopen("$depotfile", "r"))!==FALSE) {
198 198
                 
199 199
                 $columns = fgetcsv($handle, $max_line_length, $delemietr);
200 200
                 
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
                     'delete_old_depots'  => true,
209 209
                 );
210 210
                 
211
-                $iRow=1;
211
+                $iRow = 1;
212 212
                 $depotAddresses = array();
213 213
                 
214
-                while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) {
215
-                    if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) {
216
-                        $depotAddress['lat']= $rows[0];
217
-                        $depotAddress['lng']= $rows[1];
218
-                        $depotAddress['address']= $rows[3];   
219
-                        array_push($depotAddresses,$depotAddress);
214
+                while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) {
215
+                    if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) {
216
+                        $depotAddress['lat'] = $rows[0];
217
+                        $depotAddress['lng'] = $rows[1];
218
+                        $depotAddress['address'] = $rows[3];   
219
+                        array_push($depotAddresses, $depotAddress);
220 220
                     }
221 221
                 }
222 222
                 
Please login to merge, or discard this patch.