@@ -207,6 +207,7 @@ |
||
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | 209 | * @param $object: JSON object |
| 210 | + * @param \SimpleXMLElement $object |
|
| 210 | 211 | */ |
| 211 | 212 | public static function object2array($object) |
| 212 | 213 | { |
@@ -7,343 +7,343 @@ |
||
| 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 fileUploadRequest($options) { |
|
| 34 | - $query = isset($options['query']) ? array_filter($options['query']) : array(); |
|
| 33 | + public static function fileUploadRequest($options) { |
|
| 34 | + $query = isset($options['query']) ? array_filter($options['query']) : array(); |
|
| 35 | 35 | |
| 36 | - if (sizeof($query)==0) { |
|
| 37 | - return null; |
|
| 36 | + if (sizeof($query)==0) { |
|
| 37 | + return null; |
|
| 38 | 38 | |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $body = isset($options['body']) ? array_filter($options['body']) : null; |
|
| 41 | + $body = isset($options['body']) ? array_filter($options['body']) : null; |
|
| 42 | 42 | |
| 43 | - $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
|
| 43 | + $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
|
| 44 | 44 | |
| 45 | - if ($fname=='') { |
|
| 46 | - return null; |
|
| 47 | - } |
|
| 45 | + if ($fname=='') { |
|
| 46 | + return null; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
|
| 49 | + $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
|
| 50 | 50 | |
| 51 | - $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(array('api_key' => self::getApiKey()), $query)); |
|
| 51 | + $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(array('api_key' => self::getApiKey()), $query)); |
|
| 52 | 52 | |
| 53 | - $ch = curl_init($url); |
|
| 53 | + $ch = curl_init($url); |
|
| 54 | 54 | |
| 55 | - $curlOpts = array( |
|
| 56 | - CURLOPT_POST => true, |
|
| 57 | - CURLOPT_RETURNTRANSFER => false, |
|
| 58 | - CURLOPT_TIMEOUT => 60, |
|
| 59 | - CURLOPT_FOLLOWLOCATION => true, |
|
| 60 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 61 | - CURLOPT_SSL_VERIFYPEER => FALSE |
|
| 62 | - ); |
|
| 55 | + $curlOpts = array( |
|
| 56 | + CURLOPT_POST => true, |
|
| 57 | + CURLOPT_RETURNTRANSFER => false, |
|
| 58 | + CURLOPT_TIMEOUT => 60, |
|
| 59 | + CURLOPT_FOLLOWLOCATION => true, |
|
| 60 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 61 | + CURLOPT_SSL_VERIFYPEER => FALSE |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - curl_setopt_array($ch, $curlOpts); |
|
| 64 | + curl_setopt_array($ch, $curlOpts); |
|
| 65 | 65 | |
| 66 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
| 66 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
| 67 | 67 | |
| 68 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
| 69 | - "Content-Type: multipart/form-data", |
|
| 70 | - 'Content-Disposition: form-data; name="strFilename"' |
|
| 71 | - )); |
|
| 72 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
| 73 | - curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); |
|
| 68 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
| 69 | + "Content-Type: multipart/form-data", |
|
| 70 | + 'Content-Disposition: form-data; name="strFilename"' |
|
| 71 | + )); |
|
| 72 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
| 73 | + curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); |
|
| 74 | 74 | |
| 75 | - $result = curl_exec($ch); |
|
| 75 | + $result = curl_exec($ch); |
|
| 76 | 76 | |
| 77 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 78 | - curl_close($ch); |
|
| 77 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 78 | + curl_close($ch); |
|
| 79 | 79 | |
| 80 | - $json = json_decode($result, true); |
|
| 80 | + $json = json_decode($result, true); |
|
| 81 | 81 | |
| 82 | - if (200==$code) { |
|
| 83 | - return $json; |
|
| 84 | - } elseif (isset($json['errors'])) { |
|
| 85 | - throw new ApiError(implode(', ', $json['errors'])); |
|
| 86 | - } else { |
|
| 87 | - throw new ApiError('Something wrong'); |
|
| 88 | - } |
|
| 89 | - } |
|
| 82 | + if (200==$code) { |
|
| 83 | + return $json; |
|
| 84 | + } elseif (isset($json['errors'])) { |
|
| 85 | + throw new ApiError(implode(', ', $json['errors'])); |
|
| 86 | + } else { |
|
| 87 | + throw new ApiError('Something wrong'); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - public static function makeRequst($options) { |
|
| 92 | - $errorHandler = new myErrorHandler(); |
|
| 91 | + public static function makeRequst($options) { |
|
| 92 | + $errorHandler = new myErrorHandler(); |
|
| 93 | 93 | |
| 94 | - $old_error_handler = set_error_handler(array($errorHandler, "proc_error")); |
|
| 94 | + $old_error_handler = set_error_handler(array($errorHandler, "proc_error")); |
|
| 95 | 95 | |
| 96 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 97 | - $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
| 96 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 97 | + $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
| 98 | 98 | |
| 99 | - $body = isset($options['body']) ? $options['body'] : null; |
|
| 100 | - $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
| 101 | - $headers = array( |
|
| 102 | - "User-Agent: Route4Me php-sdk" |
|
| 103 | - ); |
|
| 99 | + $body = isset($options['body']) ? $options['body'] : null; |
|
| 100 | + $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
| 101 | + $headers = array( |
|
| 102 | + "User-Agent: Route4Me php-sdk" |
|
| 103 | + ); |
|
| 104 | 104 | |
| 105 | - if (isset($options['HTTPHEADER'])) { |
|
| 106 | - $headers[] = $options['HTTPHEADER']; |
|
| 107 | - } |
|
| 105 | + if (isset($options['HTTPHEADER'])) { |
|
| 106 | + $headers[] = $options['HTTPHEADER']; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if (isset($options['HTTPHEADERS'])) { |
|
| 110 | - foreach ($options['HTTPHEADERS'] As $header) { |
|
| 111 | - $headers[] = $header; |
|
| 112 | - } |
|
| 113 | - } |
|
| 109 | + if (isset($options['HTTPHEADERS'])) { |
|
| 110 | + foreach ($options['HTTPHEADERS'] As $header) { |
|
| 111 | + $headers[] = $header; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - $ch = curl_init(); |
|
| 115 | + $ch = curl_init(); |
|
| 116 | 116 | |
| 117 | - $url = $options['url'].'?'.http_build_query(array_merge( |
|
| 118 | - $query, array('api_key' => self::getApiKey()) |
|
| 119 | - )); |
|
| 117 | + $url = $options['url'].'?'.http_build_query(array_merge( |
|
| 118 | + $query, array('api_key' => self::getApiKey()) |
|
| 119 | + )); |
|
| 120 | 120 | |
| 121 | - $baseUrl = self::getBaseUrl(); |
|
| 121 | + $baseUrl = self::getBaseUrl(); |
|
| 122 | 122 | |
| 123 | - $curlOpts = arraY( |
|
| 124 | - CURLOPT_URL => $baseUrl.$url, |
|
| 125 | - CURLOPT_RETURNTRANSFER => true, |
|
| 126 | - CURLOPT_TIMEOUT => 80, |
|
| 127 | - CURLOPT_FOLLOWLOCATION => true, |
|
| 128 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 129 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
| 130 | - CURLOPT_HTTPHEADER => $headers |
|
| 131 | - ); |
|
| 123 | + $curlOpts = arraY( |
|
| 124 | + CURLOPT_URL => $baseUrl.$url, |
|
| 125 | + CURLOPT_RETURNTRANSFER => true, |
|
| 126 | + CURLOPT_TIMEOUT => 80, |
|
| 127 | + CURLOPT_FOLLOWLOCATION => true, |
|
| 128 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 129 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
| 130 | + CURLOPT_HTTPHEADER => $headers |
|
| 131 | + ); |
|
| 132 | 132 | |
| 133 | - curl_setopt_array($ch, $curlOpts); |
|
| 133 | + curl_setopt_array($ch, $curlOpts); |
|
| 134 | 134 | |
| 135 | - if ($file!=null) { |
|
| 136 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
|
| 137 | - $fp=fopen($file, 'r'); |
|
| 138 | - curl_setopt($ch, CURLOPT_INFILE, $fp); |
|
| 139 | - curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
|
| 140 | - } |
|
| 135 | + if ($file!=null) { |
|
| 136 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
|
| 137 | + $fp=fopen($file, 'r'); |
|
| 138 | + curl_setopt($ch, CURLOPT_INFILE, $fp); |
|
| 139 | + curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - switch ($method) { |
|
| 143 | - case 'DELETE': |
|
| 144 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 145 | - break; |
|
| 146 | - case 'DELETEARRAY': |
|
| 147 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 148 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 149 | - break; |
|
| 150 | - case 'PUT': |
|
| 151 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
| 152 | - break; |
|
| 153 | - case 'POST': |
|
| 154 | - if (isset($body)) { |
|
| 155 | - $bodyData = json_encode($body); |
|
| 156 | - if (isset($options['HTTPHEADER'])) { |
|
| 157 | - if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) { |
|
| 158 | - $bodyData = $body; |
|
| 159 | - } |
|
| 160 | - } |
|
| 142 | + switch ($method) { |
|
| 143 | + case 'DELETE': |
|
| 144 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 145 | + break; |
|
| 146 | + case 'DELETEARRAY': |
|
| 147 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 148 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 149 | + break; |
|
| 150 | + case 'PUT': |
|
| 151 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
| 152 | + break; |
|
| 153 | + case 'POST': |
|
| 154 | + if (isset($body)) { |
|
| 155 | + $bodyData = json_encode($body); |
|
| 156 | + if (isset($options['HTTPHEADER'])) { |
|
| 157 | + if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) { |
|
| 158 | + $bodyData = $body; |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 163 | - } |
|
| 164 | - break; |
|
| 165 | - case 'ADD': |
|
| 166 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
| 167 | - } |
|
| 162 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 163 | + } |
|
| 164 | + break; |
|
| 165 | + case 'ADD': |
|
| 166 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if (is_numeric(array_search($method, array('DELETE', 'PUT')))) { |
|
| 170 | - if (isset($body)) { |
|
| 171 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 172 | - } |
|
| 173 | - } |
|
| 169 | + if (is_numeric(array_search($method, array('DELETE', 'PUT')))) { |
|
| 170 | + if (isset($body)) { |
|
| 171 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - $result = curl_exec($ch); |
|
| 175 | + $result = curl_exec($ch); |
|
| 176 | 176 | |
| 177 | - $isxml = FALSE; |
|
| 178 | - $jxml = ""; |
|
| 179 | - if (strpos($result, '<?xml')>-1) { |
|
| 180 | - $xml = simplexml_load_string($result); |
|
| 181 | - //$jxml = json_encode($xml); |
|
| 182 | - $jxml = self::object2array($xml); |
|
| 183 | - $isxml = TRUE; |
|
| 184 | - } |
|
| 177 | + $isxml = FALSE; |
|
| 178 | + $jxml = ""; |
|
| 179 | + if (strpos($result, '<?xml')>-1) { |
|
| 180 | + $xml = simplexml_load_string($result); |
|
| 181 | + //$jxml = json_encode($xml); |
|
| 182 | + $jxml = self::object2array($xml); |
|
| 183 | + $isxml = TRUE; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 187 | - curl_close($ch); |
|
| 186 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 187 | + curl_close($ch); |
|
| 188 | 188 | |
| 189 | - if (200==$code) { |
|
| 190 | - if ($isxml) { |
|
| 191 | - $json = $jxml; |
|
| 192 | - } else { |
|
| 193 | - $json = json_decode($result, true); |
|
| 194 | - } |
|
| 189 | + if (200==$code) { |
|
| 190 | + if ($isxml) { |
|
| 191 | + $json = $jxml; |
|
| 192 | + } else { |
|
| 193 | + $json = json_decode($result, true); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - if (isset($json['errors'])) { |
|
| 197 | - throw new ApiError(implode(', ', $json['errors'])); |
|
| 198 | - } else { |
|
| 199 | - return $json; |
|
| 200 | - } |
|
| 201 | - } elseif (409==$code) { |
|
| 202 | - throw new ApiError('Wrong API key'); |
|
| 203 | - } else { |
|
| 204 | - throw new ApiError('Something wrong'); |
|
| 205 | - } |
|
| 206 | - } |
|
| 196 | + if (isset($json['errors'])) { |
|
| 197 | + throw new ApiError(implode(', ', $json['errors'])); |
|
| 198 | + } else { |
|
| 199 | + return $json; |
|
| 200 | + } |
|
| 201 | + } elseif (409==$code) { |
|
| 202 | + throw new ApiError('Wrong API key'); |
|
| 203 | + } else { |
|
| 204 | + throw new ApiError('Something wrong'); |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - /** |
|
| 209 | - * @param $object: JSON object |
|
| 210 | - */ |
|
| 211 | - public static function object2array($object) |
|
| 212 | - { |
|
| 213 | - return @json_decode(@json_encode($object), 1); |
|
| 214 | - } |
|
| 208 | + /** |
|
| 209 | + * @param $object: JSON object |
|
| 210 | + */ |
|
| 211 | + public static function object2array($object) |
|
| 212 | + { |
|
| 213 | + return @json_decode(@json_encode($object), 1); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - public static function makeUrlRequst($url, $options) { |
|
| 217 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 218 | - $query = isset($options['query']) ? |
|
| 219 | - array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
| 220 | - $body = isset($options['body']) ? $options['body'] : null; |
|
| 221 | - $ch = curl_init(); |
|
| 216 | + public static function makeUrlRequst($url, $options) { |
|
| 217 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 218 | + $query = isset($options['query']) ? |
|
| 219 | + array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
| 220 | + $body = isset($options['body']) ? $options['body'] : null; |
|
| 221 | + $ch = curl_init(); |
|
| 222 | 222 | |
| 223 | - $curlOpts = arraY( |
|
| 224 | - CURLOPT_URL => $url, |
|
| 225 | - CURLOPT_RETURNTRANSFER => true, |
|
| 226 | - CURLOPT_TIMEOUT => 60, |
|
| 227 | - CURLOPT_FOLLOWLOCATION => true, |
|
| 228 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 229 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
| 230 | - CURLOPT_HTTPHEADER => array( |
|
| 231 | - 'User-Agent' => 'Route4Me php-sdk' |
|
| 232 | - ) |
|
| 233 | - ); |
|
| 223 | + $curlOpts = arraY( |
|
| 224 | + CURLOPT_URL => $url, |
|
| 225 | + CURLOPT_RETURNTRANSFER => true, |
|
| 226 | + CURLOPT_TIMEOUT => 60, |
|
| 227 | + CURLOPT_FOLLOWLOCATION => true, |
|
| 228 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 229 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
| 230 | + CURLOPT_HTTPHEADER => array( |
|
| 231 | + 'User-Agent' => 'Route4Me php-sdk' |
|
| 232 | + ) |
|
| 233 | + ); |
|
| 234 | 234 | |
| 235 | - curl_setopt_array($ch, $curlOpts); |
|
| 235 | + curl_setopt_array($ch, $curlOpts); |
|
| 236 | 236 | |
| 237 | - switch ($method) { |
|
| 238 | - case 'DELETE': |
|
| 239 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 240 | - break; |
|
| 241 | - case 'DELETEARRAY': |
|
| 242 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 243 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 244 | - break; |
|
| 245 | - case 'PUT': |
|
| 246 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
| 247 | - break; |
|
| 248 | - case 'POST': |
|
| 249 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
| 250 | - break; |
|
| 251 | - case 'ADD': |
|
| 252 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
| 253 | - } |
|
| 237 | + switch ($method) { |
|
| 238 | + case 'DELETE': |
|
| 239 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 240 | + break; |
|
| 241 | + case 'DELETEARRAY': |
|
| 242 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 243 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 244 | + break; |
|
| 245 | + case 'PUT': |
|
| 246 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
| 247 | + break; |
|
| 248 | + case 'POST': |
|
| 249 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
| 250 | + break; |
|
| 251 | + case 'ADD': |
|
| 252 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - if (is_numeric(array_search($method, array('DELETE', 'PUT', 'POST')))) { |
|
| 256 | - if (isset($body)) { |
|
| 257 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 258 | - } |
|
| 259 | - } |
|
| 255 | + if (is_numeric(array_search($method, array('DELETE', 'PUT', 'POST')))) { |
|
| 256 | + if (isset($body)) { |
|
| 257 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - $result = curl_exec($ch); |
|
| 261 | + $result = curl_exec($ch); |
|
| 262 | 262 | |
| 263 | - $isxml = FALSE; |
|
| 264 | - $jxml = ""; |
|
| 263 | + $isxml = FALSE; |
|
| 264 | + $jxml = ""; |
|
| 265 | 265 | |
| 266 | - if (strpos($result, '<?xml')>-1) { |
|
| 267 | - $xml = simplexml_load_string($result); |
|
| 268 | - $jxml = json_encode($xml); |
|
| 269 | - $isxml = TRUE; |
|
| 270 | - } |
|
| 266 | + if (strpos($result, '<?xml')>-1) { |
|
| 267 | + $xml = simplexml_load_string($result); |
|
| 268 | + $jxml = json_encode($xml); |
|
| 269 | + $isxml = TRUE; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 273 | - curl_close($ch); |
|
| 272 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 273 | + curl_close($ch); |
|
| 274 | 274 | |
| 275 | - if ($isxml) { |
|
| 276 | - $json = $jxml; |
|
| 277 | - } else { |
|
| 278 | - $json = json_decode($result, true); |
|
| 279 | - } |
|
| 275 | + if ($isxml) { |
|
| 276 | + $json = $jxml; |
|
| 277 | + } else { |
|
| 278 | + $json = json_decode($result, true); |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - if (200==$code) { |
|
| 282 | - return $json; |
|
| 283 | - } elseif (isset($json['errors'])) { |
|
| 284 | - throw new ApiError(implode(', ', $json['errors'])); |
|
| 285 | - } else { |
|
| 286 | - throw new ApiError('Something wrong'); |
|
| 287 | - } |
|
| 288 | - } |
|
| 281 | + if (200==$code) { |
|
| 282 | + return $json; |
|
| 283 | + } elseif (isset($json['errors'])) { |
|
| 284 | + throw new ApiError(implode(', ', $json['errors'])); |
|
| 285 | + } else { |
|
| 286 | + throw new ApiError('Something wrong'); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - /** |
|
| 291 | - * Prints on the screen main keys and values of the array |
|
| 292 | - * @param $results: object to be printed on the screen. |
|
| 293 | - * @param $deepPrinting: if true, object will be printed recursively. |
|
| 294 | - */ |
|
| 295 | - public static function simplePrint($results, $deepPrinting = null) |
|
| 296 | - { |
|
| 297 | - if (isset($results)) { |
|
| 298 | - if (is_array($results)) { |
|
| 299 | - foreach ($results as $key=>$result) { |
|
| 300 | - if (is_array($result)) { |
|
| 301 | - foreach ($result as $key1=>$result1) { |
|
| 302 | - if (is_array($result1)) { |
|
| 303 | - if ($deepPrinting) { |
|
| 304 | - echo "<br>$key1 ------><br>"; |
|
| 305 | - Route4Me::simplePrint($result1, true); |
|
| 306 | - echo "------<br>"; |
|
| 307 | - } else { |
|
| 308 | - echo $key1." --> "."Array() <br>"; |
|
| 309 | - } |
|
| 310 | - } else { |
|
| 311 | - if (is_object($result1)) { |
|
| 312 | - if ($deepPrinting) { |
|
| 313 | - echo "<br>$key1 ------><br>"; |
|
| 314 | - $oarray = (array)$result1; |
|
| 315 | - Route4Me::simplePrint($oarray, true); |
|
| 316 | - echo "------<br>"; |
|
| 317 | - } else { |
|
| 318 | - echo $key1." --> "."Object <br>"; |
|
| 319 | - } |
|
| 320 | - } else { |
|
| 321 | - if (!is_null($result1)) { |
|
| 322 | - echo $key1." --> ".$result1."<br>"; |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - } else { |
|
| 328 | - if (is_object($result)) { |
|
| 329 | - if ($deepPrinting) { |
|
| 330 | - echo "<br>$key ------><br>"; |
|
| 331 | - $oarray = (array)$result; |
|
| 332 | - Route4Me::simplePrint($oarray, true); |
|
| 333 | - echo "------<br>"; |
|
| 334 | - } else { |
|
| 335 | - echo $key." --> "."Object <br>"; |
|
| 336 | - } |
|
| 337 | - } else { |
|
| 338 | - if (!is_null($result)) { |
|
| 339 | - echo $key." --> ".$result."<br>"; |
|
| 340 | - } |
|
| 341 | - } |
|
| 290 | + /** |
|
| 291 | + * Prints on the screen main keys and values of the array |
|
| 292 | + * @param $results: object to be printed on the screen. |
|
| 293 | + * @param $deepPrinting: if true, object will be printed recursively. |
|
| 294 | + */ |
|
| 295 | + public static function simplePrint($results, $deepPrinting = null) |
|
| 296 | + { |
|
| 297 | + if (isset($results)) { |
|
| 298 | + if (is_array($results)) { |
|
| 299 | + foreach ($results as $key=>$result) { |
|
| 300 | + if (is_array($result)) { |
|
| 301 | + foreach ($result as $key1=>$result1) { |
|
| 302 | + if (is_array($result1)) { |
|
| 303 | + if ($deepPrinting) { |
|
| 304 | + echo "<br>$key1 ------><br>"; |
|
| 305 | + Route4Me::simplePrint($result1, true); |
|
| 306 | + echo "------<br>"; |
|
| 307 | + } else { |
|
| 308 | + echo $key1." --> "."Array() <br>"; |
|
| 309 | + } |
|
| 310 | + } else { |
|
| 311 | + if (is_object($result1)) { |
|
| 312 | + if ($deepPrinting) { |
|
| 313 | + echo "<br>$key1 ------><br>"; |
|
| 314 | + $oarray = (array)$result1; |
|
| 315 | + Route4Me::simplePrint($oarray, true); |
|
| 316 | + echo "------<br>"; |
|
| 317 | + } else { |
|
| 318 | + echo $key1." --> "."Object <br>"; |
|
| 319 | + } |
|
| 320 | + } else { |
|
| 321 | + if (!is_null($result1)) { |
|
| 322 | + echo $key1." --> ".$result1."<br>"; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + } else { |
|
| 328 | + if (is_object($result)) { |
|
| 329 | + if ($deepPrinting) { |
|
| 330 | + echo "<br>$key ------><br>"; |
|
| 331 | + $oarray = (array)$result; |
|
| 332 | + Route4Me::simplePrint($oarray, true); |
|
| 333 | + echo "------<br>"; |
|
| 334 | + } else { |
|
| 335 | + echo $key." --> "."Object <br>"; |
|
| 336 | + } |
|
| 337 | + } else { |
|
| 338 | + if (!is_null($result)) { |
|
| 339 | + echo $key." --> ".$result."<br>"; |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - } |
|
| 344 | - //echo "<br>"; |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - } |
|
| 343 | + } |
|
| 344 | + //echo "<br>"; |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | 349 | } |
@@ -134,7 +134,7 @@ |
||
| 134 | 134 | |
| 135 | 135 | if ($file!=null) { |
| 136 | 136 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
| 137 | - $fp=fopen($file, 'r'); |
|
| 137 | + $fp = fopen($file, 'r'); |
|
| 138 | 138 | curl_setopt($ch, CURLOPT_INFILE, $fp); |
| 139 | 139 | curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
| 140 | 140 | } |
@@ -198,7 +198,7 @@ |
||
| 198 | 198 | } else { |
| 199 | 199 | return $json; |
| 200 | 200 | } |
| 201 | - } elseif (409==$code) { |
|
| 201 | + } elseif (409==$code) { |
|
| 202 | 202 | throw new ApiError('Wrong API key'); |
| 203 | 203 | } else { |
| 204 | 204 | throw new ApiError('Something wrong'); |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | Route4Me::setApiKey('11111111111111111111111111111111'); |
| 15 | 15 | |
| 16 | 16 | $activityParameters = ActivityParameters::fromArray(array( |
| 17 | - "limit" => 10, |
|
| 18 | - "offset" => 0 |
|
| 17 | + "limit" => 10, |
|
| 18 | + "offset" => 0 |
|
| 19 | 19 | )); |
| 20 | 20 | |
| 21 | 21 | $activities = new ActivityParameters(); |
@@ -23,6 +23,6 @@ discard block |
||
| 23 | 23 | $results = $activities->getValue($actresults, "results"); |
| 24 | 24 | |
| 25 | 25 | foreach ($results as $result) { |
| 26 | - Route4Me::simplePrint($result); |
|
| 27 | - echo "<br>"; |
|
| 26 | + Route4Me::simplePrint($result); |
|
| 27 | + echo "<br>"; |
|
| 28 | 28 | } |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | Route4Me::setApiKey('11111111111111111111111111111111'); |
| 17 | 17 | |
| 18 | 18 | $activityParameters = ActivityParameters::fromArray(array( |
| 19 | - "limit" => 10, |
|
| 20 | - "offset" => 0, |
|
| 21 | - "start" => strtotime("-1 week") |
|
| 19 | + "limit" => 10, |
|
| 20 | + "offset" => 0, |
|
| 21 | + "start" => strtotime("-1 week") |
|
| 22 | 22 | )); |
| 23 | 23 | |
| 24 | 24 | $activities = new ActivityParameters(); |
@@ -26,6 +26,6 @@ discard block |
||
| 26 | 26 | $results = $activities->getValue($actresults, "results"); |
| 27 | 27 | |
| 28 | 28 | foreach ($results as $result) { |
| 29 | - Route4Me::simplePrint($result); |
|
| 30 | - echo "<br>"; |
|
| 29 | + Route4Me::simplePrint($result); |
|
| 30 | + echo "<br>"; |
|
| 31 | 31 | } |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
| 8 | 8 | use Route4Me\Route; |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
| 8 | 8 | use Route4Me\Route; |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
| 8 | 8 | use Route4Me\Route; |
@@ -44,21 +44,21 @@ discard block |
||
| 44 | 44 | $locationsFieldsMapping['monthly_nth_wwhat'] = 17; |
| 45 | 45 | |
| 46 | 46 | if (($handle = fopen("$source_file", "r"))!==FALSE) { |
| 47 | - $oAbook = new AddressBookLocation(); |
|
| 47 | + $oAbook = new AddressBookLocation(); |
|
| 48 | 48 | |
| 49 | - $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); |
|
| 49 | + $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); |
|
| 50 | 50 | |
| 51 | - echo "Errors: <br><br>"; |
|
| 51 | + echo "Errors: <br><br>"; |
|
| 52 | 52 | |
| 53 | - foreach ($results['fail'] as $evalue) { |
|
| 54 | - echo $evalue."<br>"; |
|
| 55 | - } |
|
| 53 | + foreach ($results['fail'] as $evalue) { |
|
| 54 | + echo $evalue."<br>"; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - echo "Successes: <br><br>"; |
|
| 57 | + echo "Successes: <br><br>"; |
|
| 58 | 58 | |
| 59 | - foreach ($results['success'] as $svalue) { |
|
| 60 | - echo $svalue."<br>"; |
|
| 61 | - } |
|
| 59 | + foreach ($results['success'] as $svalue) { |
|
| 60 | + echo $svalue."<br>"; |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /* Add orders with schedules from a CSV file */ |
@@ -78,20 +78,20 @@ discard block |
||
| 78 | 78 | $ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8; |
| 79 | 79 | |
| 80 | 80 | if (($handle = fopen("$orders_file", "r"))!==FALSE) { |
| 81 | - $order = new Order(); |
|
| 82 | - $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
| 81 | + $order = new Order(); |
|
| 82 | + $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
| 83 | 83 | |
| 84 | - echo "Errors: <br><br>"; |
|
| 84 | + echo "Errors: <br><br>"; |
|
| 85 | 85 | |
| 86 | - foreach ($results['fail'] as $evalue) { |
|
| 87 | - echo $evalue."<br>"; |
|
| 88 | - } |
|
| 86 | + foreach ($results['fail'] as $evalue) { |
|
| 87 | + echo $evalue."<br>"; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - echo "Successes: <br><br>"; |
|
| 90 | + echo "Successes: <br><br>"; |
|
| 91 | 91 | |
| 92 | - foreach ($results['success'] as $svalue) { |
|
| 93 | - echo $svalue."<br>"; |
|
| 94 | - } |
|
| 92 | + foreach ($results['success'] as $svalue) { |
|
| 93 | + echo $svalue."<br>"; |
|
| 94 | + } |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /* Get Hybrid Optimization */ |
@@ -100,63 +100,63 @@ discard block |
||
| 100 | 100 | $sched_date = date("Y-m-d", $ep); |
| 101 | 101 | |
| 102 | 102 | $hybridParams = array( |
| 103 | - "target_date_string" => $sched_date, |
|
| 104 | - "timezone_offset_minutes" => 480 |
|
| 103 | + "target_date_string" => $sched_date, |
|
| 104 | + "timezone_offset_minutes" => 480 |
|
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | $optimization = new OptimizationProblem(); |
| 108 | 108 | $hybridOptimization = $optimization->getHybridOptimization($hybridParams); |
| 109 | 109 | |
| 110 | 110 | if ($hybridOptimization!=null) { |
| 111 | - if (isset($hybridOptimization['optimization_problem_id'])) { |
|
| 112 | - $optid = $hybridOptimization['optimization_problem_id']; |
|
| 111 | + if (isset($hybridOptimization['optimization_problem_id'])) { |
|
| 112 | + $optid = $hybridOptimization['optimization_problem_id']; |
|
| 113 | 113 | |
| 114 | - echo "Hibrid optimization with optimization_problem_id = $optid <br><br>"; |
|
| 114 | + echo "Hibrid optimization with optimization_problem_id = $optid <br><br>"; |
|
| 115 | 115 | |
| 116 | - /* Add depots to the Hybrid Optimization */ |
|
| 117 | - $depotfile = "depots.csv"; |
|
| 116 | + /* Add depots to the Hybrid Optimization */ |
|
| 117 | + $depotfile = "depots.csv"; |
|
| 118 | 118 | |
| 119 | - if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
| 120 | - $columns = fgetcsv($handle, $max_line_length, $delemietr); |
|
| 119 | + if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
| 120 | + $columns = fgetcsv($handle, $max_line_length, $delemietr); |
|
| 121 | 121 | |
| 122 | - if (empty($columns)) { |
|
| 123 | - $error['message'] = 'Empty'; |
|
| 124 | - return ($error); |
|
| 125 | - } |
|
| 122 | + if (empty($columns)) { |
|
| 123 | + $error['message'] = 'Empty'; |
|
| 124 | + return ($error); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - $depotsParams = array( |
|
| 128 | - 'optimization_problem_id' => $optid, |
|
| 129 | - 'delete_old_depots' => true, |
|
| 130 | - ); |
|
| 127 | + $depotsParams = array( |
|
| 128 | + 'optimization_problem_id' => $optid, |
|
| 129 | + 'delete_old_depots' => true, |
|
| 130 | + ); |
|
| 131 | 131 | |
| 132 | - $iRow = 1; |
|
| 133 | - $depotAddresses = array(); |
|
| 132 | + $iRow = 1; |
|
| 133 | + $depotAddresses = array(); |
|
| 134 | 134 | |
| 135 | - while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) { |
|
| 136 | - if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
| 137 | - $depotAddress['lat'] = $rows[0]; |
|
| 138 | - $depotAddress['lng'] = $rows[1]; |
|
| 139 | - $depotAddress['address'] = $rows[3]; |
|
| 140 | - array_push($depotAddresses, $depotAddress); |
|
| 141 | - } |
|
| 142 | - } |
|
| 135 | + while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) { |
|
| 136 | + if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
| 137 | + $depotAddress['lat'] = $rows[0]; |
|
| 138 | + $depotAddress['lng'] = $rows[1]; |
|
| 139 | + $depotAddress['address'] = $rows[3]; |
|
| 140 | + array_push($depotAddresses, $depotAddress); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - $depotsParams['new_depots'] = $depotAddresses; |
|
| 144 | + $depotsParams['new_depots'] = $depotAddresses; |
|
| 145 | 145 | |
| 146 | - $optProblem = new OptimizationProblem(); |
|
| 146 | + $optProblem = new OptimizationProblem(); |
|
| 147 | 147 | |
| 148 | - $resultDepots = $optProblem->addDepotsToHybrid($depotsParams); |
|
| 148 | + $resultDepots = $optProblem->addDepotsToHybrid($depotsParams); |
|
| 149 | 149 | |
| 150 | - /* Reoptimize hybrid optimization */ |
|
| 150 | + /* Reoptimize hybrid optimization */ |
|
| 151 | 151 | |
| 152 | - if ($resultDepots!=null) { |
|
| 153 | - $problemParams = array( |
|
| 154 | - 'optimization_problem_id' => $optid |
|
| 155 | - ); |
|
| 156 | - $problem = OptimizationProblem::reoptimize($problemParams); |
|
| 152 | + if ($resultDepots!=null) { |
|
| 153 | + $problemParams = array( |
|
| 154 | + 'optimization_problem_id' => $optid |
|
| 155 | + ); |
|
| 156 | + $problem = OptimizationProblem::reoptimize($problemParams); |
|
| 157 | 157 | |
| 158 | - Route4Me::simplePrint($problem); |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - } |
|
| 158 | + Route4Me::simplePrint($problem); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | 162 | } |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | |
| 97 | 97 | /* Get Hybrid Optimization */ |
| 98 | 98 | |
| 99 | -$ep = time()+604800; |
|
| 99 | +$ep = time() + 604800; |
|
| 100 | 100 | $sched_date = date("Y-m-d", $ep); |
| 101 | 101 | |
| 102 | 102 | $hybridParams = array( |
@@ -16,14 +16,14 @@ |
||
| 16 | 16 | |
| 17 | 17 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
| 18 | 18 | $territoryParams['data'] = array( |
| 19 | - "37.569752822786455,-77.47833251953125", |
|
| 20 | - "5000" |
|
| 19 | + "37.569752822786455,-77.47833251953125", |
|
| 20 | + "5000" |
|
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | 23 | $AvoidanceZoneParameters = AvoidanceZone::fromArray(array( |
| 24 | - "territory_name" => "Test Circle Avoidance Zone ".strval(rand(10000,99999)), |
|
| 25 | - "territory_color" => "ff7700", |
|
| 26 | - "territory" => $territoryParams |
|
| 24 | + "territory_name" => "Test Circle Avoidance Zone ".strval(rand(10000,99999)), |
|
| 25 | + "territory_color" => "ff7700", |
|
| 26 | + "territory" => $territoryParams |
|
| 27 | 27 | )); |
| 28 | 28 | |
| 29 | 29 | $avoidancezone = new AvoidanceZone(); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
| 8 | 8 | use Route4Me\Enum\TerritoryTypes; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | 23 | $AvoidanceZoneParameters = AvoidanceZone::fromArray(array( |
| 24 | - "territory_name" => "Test Circle Avoidance Zone ".strval(rand(10000,99999)), |
|
| 24 | + "territory_name" => "Test Circle Avoidance Zone ".strval(rand(10000, 99999)), |
|
| 25 | 25 | "territory_color" => "ff7700", |
| 26 | 26 | "territory" => $territoryParams |
| 27 | 27 | )); |
@@ -16,14 +16,14 @@ |
||
| 16 | 16 | |
| 17 | 17 | $territoryParams['type'] = TerritoryTypes::RECT; |
| 18 | 18 | $territoryParams['data'] = array( |
| 19 | - "43.51668853502909,-109.3798828125", |
|
| 20 | - "46.98025235521883,-101.865234375" |
|
| 19 | + "43.51668853502909,-109.3798828125", |
|
| 20 | + "46.98025235521883,-101.865234375" |
|
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | 23 | $AvoidanceZoneParameters = AvoidanceZone::fromArray(array( |
| 24 | - "territory_name" => "Test Rectangular Avoidance Zone ".strval(rand(10000,99999)), |
|
| 25 | - "territory_color" => "ff7700", |
|
| 26 | - "territory" => $territoryParams |
|
| 24 | + "territory_name" => "Test Rectangular Avoidance Zone ".strval(rand(10000,99999)), |
|
| 25 | + "territory_color" => "ff7700", |
|
| 26 | + "territory" => $territoryParams |
|
| 27 | 27 | )); |
| 28 | 28 | |
| 29 | 29 | $avoidancezone = new AvoidanceZone(); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
| 8 | 8 | use Route4Me\Enum\TerritoryTypes; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | 23 | $AvoidanceZoneParameters = AvoidanceZone::fromArray(array( |
| 24 | - "territory_name" => "Test Rectangular Avoidance Zone ".strval(rand(10000,99999)), |
|
| 24 | + "territory_name" => "Test Rectangular Avoidance Zone ".strval(rand(10000, 99999)), |
|
| 25 | 25 | "territory_color" => "ff7700", |
| 26 | 26 | "territory" => $territoryParams |
| 27 | 27 | )); |
@@ -16,21 +16,21 @@ |
||
| 16 | 16 | |
| 17 | 17 | $territoryParams['type'] = TerritoryTypes::POLY; |
| 18 | 18 | $territoryParams['data'] = array( |
| 19 | - "37.769752822786455,-77.67833251953125", |
|
| 20 | - "37.75886716305343,-77.68974800109863", |
|
| 21 | - "37.74763966054455,-77.6917221069336", |
|
| 22 | - "37.74655084306813,-77.68863220214844", |
|
| 23 | - "37.7502255383101,-77.68125076293945", |
|
| 24 | - "37.74797991274437,-77.67498512268066", |
|
| 25 | - "37.73327960206065,-77.6411678314209", |
|
| 26 | - "37.74430510679532,-77.63172645568848", |
|
| 27 | - "37.76641925847049,-77.66846199035645" |
|
| 19 | + "37.769752822786455,-77.67833251953125", |
|
| 20 | + "37.75886716305343,-77.68974800109863", |
|
| 21 | + "37.74763966054455,-77.6917221069336", |
|
| 22 | + "37.74655084306813,-77.68863220214844", |
|
| 23 | + "37.7502255383101,-77.68125076293945", |
|
| 24 | + "37.74797991274437,-77.67498512268066", |
|
| 25 | + "37.73327960206065,-77.6411678314209", |
|
| 26 | + "37.74430510679532,-77.63172645568848", |
|
| 27 | + "37.76641925847049,-77.66846199035645" |
|
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | 30 | $AvoidanceZoneParameters = AvoidanceZone::fromArray(array( |
| 31 | - "territory_name" => "Test Poligonian Avoidance Zone ".strval(rand(10000,99999)), |
|
| 32 | - "territory_color" => "ff7700", |
|
| 33 | - "territory" => $territoryParams |
|
| 31 | + "territory_name" => "Test Poligonian Avoidance Zone ".strval(rand(10000,99999)), |
|
| 32 | + "territory_color" => "ff7700", |
|
| 33 | + "territory" => $territoryParams |
|
| 34 | 34 | )); |
| 35 | 35 | |
| 36 | 36 | $avoidancezone = new AvoidanceZone(); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
| 8 | 8 | use Route4Me\Enum\TerritoryTypes; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | 30 | $AvoidanceZoneParameters = AvoidanceZone::fromArray(array( |
| 31 | - "territory_name" => "Test Poligonian Avoidance Zone ".strval(rand(10000,99999)), |
|
| 31 | + "territory_name" => "Test Poligonian Avoidance Zone ".strval(rand(10000, 99999)), |
|
| 32 | 32 | "territory_color" => "ff7700", |
| 33 | 33 | "territory" => $territoryParams |
| 34 | 34 | )); |