@@ -258,7 +258,7 @@ |
||
258 | 258 | /** |
259 | 259 | * Gets last operation error, if any |
260 | 260 | * @access public |
261 | - * @return WSClientError The error object |
|
261 | + * @return boolean The error object |
|
262 | 262 | */ |
263 | 263 | public function getLastError() |
264 | 264 | { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if (!preg_match('/^https?:\/\//i', $url)) { |
78 | 78 | $url = sprintf('http://%s', $url); |
79 | 79 | } |
80 | - if (strripos($url, '/') != (strlen($url)-1)) { |
|
80 | + if (strripos($url, '/') != (strlen($url) - 1)) { |
|
81 | 81 | $url .= '/'; |
82 | 82 | } |
83 | 83 | |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | */ |
96 | 96 | private function checkForError(array $jsonResult) // TODO move checkForError body to sendHttpRequest method's body |
97 | 97 | { |
98 | - if (isset($jsonResult['success']) && (bool)$jsonResult['success'] === true) { |
|
98 | + if (isset($jsonResult[ 'success' ]) && (bool) $jsonResult[ 'success' ] === true) { |
|
99 | 99 | $this->lastErrorMessage = null; |
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $this->lastErrorMessage = new WSClientError( |
104 | - $jsonResult['error']['message'], |
|
105 | - $jsonResult['error']['code'] |
|
104 | + $jsonResult[ 'error' ][ 'message' ], |
|
105 | + $jsonResult[ 'error' ][ 'code' ] |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | return true; |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | try { |
133 | 133 | switch ($method) { |
134 | 134 | case 'GET': |
135 | - $response = $this->httpClient->get($this->serviceBaseURL, ['query' => $requestData]); |
|
135 | + $response = $this->httpClient->get($this->serviceBaseURL, [ 'query' => $requestData ]); |
|
136 | 136 | break; |
137 | 137 | case 'POST': |
138 | - $response = $this->httpClient->post($this->serviceBaseURL, ['form_params' => $requestData]); |
|
138 | + $response = $this->httpClient->post($this->serviceBaseURL, [ 'form_params' => $requestData ]); |
|
139 | 139 | break; |
140 | 140 | default: |
141 | 141 | $this->lastErrorMessage = new WSClientError("Unknown request type {$method}"); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | return (!is_array($jsonObj) || $this->checkForError($jsonObj)) |
156 | 156 | ? null |
157 | - : $jsonObj['result']; |
|
157 | + : $jsonObj[ 'result' ]; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | ]; |
172 | 172 | $result = $this->sendHttpRequest($getdata, 'GET'); |
173 | 173 | |
174 | - if (!is_array($result) || !isset($result['token'])) { |
|
174 | + if (!is_array($result) || !isset($result[ 'token' ])) { |
|
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | |
178 | - $this->serviceServerTime = $result['serverTime']; |
|
179 | - $this->serviceExpireTime = $result['expireTime']; |
|
180 | - $this->serviceToken = $result['token']; |
|
178 | + $this->serviceServerTime = $result[ 'serverTime' ]; |
|
179 | + $this->serviceExpireTime = $result[ 'expireTime' ]; |
|
180 | + $this->serviceToken = $result[ 'token' ]; |
|
181 | 181 | |
182 | 182 | return true; |
183 | 183 | } |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | $this->accessKey = $accessKey; |
213 | 213 | |
214 | 214 | // Session data |
215 | - $this->sessionName = $result['sessionName']; |
|
216 | - $this->userID = $result['userId']; |
|
215 | + $this->sessionName = $result[ 'sessionName' ]; |
|
216 | + $this->userID = $result[ 'userId' ]; |
|
217 | 217 | |
218 | 218 | // Vtiger CRM and WebServices API version |
219 | - $this->apiVersion = $result['version']; |
|
220 | - $this->vtigerVersion = $result['vtigerVersion']; |
|
219 | + $this->apiVersion = $result[ 'version' ]; |
|
220 | + $this->vtigerVersion = $result[ 'vtigerVersion' ]; |
|
221 | 221 | |
222 | 222 | return true; |
223 | 223 | } |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | $accessKey = array_key_exists('accesskey', $result) |
252 | - ? $result['accesskey'] |
|
253 | - : $result[0]; |
|
252 | + ? $result[ 'accesskey' ] |
|
253 | + : $result[ 0 ]; |
|
254 | 254 | |
255 | 255 | return $this->login($username, $accessKey); |
256 | 256 | } |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | ]; |
293 | 293 | |
294 | 294 | $result = $this->sendHttpRequest($getdata, 'GET'); |
295 | - $modules = $result['types']; |
|
295 | + $modules = $result[ 'types' ]; |
|
296 | 296 | |
297 | 297 | $result = array(); |
298 | 298 | foreach ($modules as $moduleName) { |
299 | - $result[$moduleName] = ['name' => $moduleName]; |
|
299 | + $result[ $moduleName ] = [ 'name' => $moduleName ]; |
|
300 | 300 | } |
301 | 301 | return $result; |
302 | 302 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | private function getTypedID($moduleName, $entityID) |
332 | 332 | { |
333 | - if (stripos((string)$entityID, 'x') !== false) { |
|
333 | + if (stripos((string) $entityID, 'x') !== false) { |
|
334 | 334 | return $entityID; |
335 | 335 | } |
336 | 336 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | |
344 | - return "{$type['idPrefix']}x{$entityID}"; |
|
344 | + return "{$type[ 'idPrefix' ]}x{$entityID}"; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $this->checkLogin(); |
388 | 388 | |
389 | 389 | // Make sure the query ends with ; |
390 | - $query = (strripos($query, ';') != strlen($query)-1) |
|
390 | + $query = (strripos($query, ';') != strlen($query) - 1) |
|
391 | 391 | ? trim($query .= ';') |
392 | 392 | : trim($query); |
393 | 393 | |
@@ -442,23 +442,23 @@ discard block |
||
442 | 442 | |
443 | 443 | // Build the query |
444 | 444 | $criteria = array(); |
445 | - $query="SELECT id FROM $moduleName WHERE "; |
|
445 | + $query = "SELECT id FROM $moduleName WHERE "; |
|
446 | 446 | foreach ($params as $param => $value) { |
447 | - $criteria[] = "{$param} LIKE '{$value}'"; |
|
447 | + $criteria[ ] = "{$param} LIKE '{$value}'"; |
|
448 | 448 | } |
449 | 449 | |
450 | - $query.=implode(" AND ", $criteria); |
|
451 | - $query.=" LIMIT 1"; |
|
450 | + $query .= implode(" AND ", $criteria); |
|
451 | + $query .= " LIMIT 1"; |
|
452 | 452 | |
453 | 453 | $records = $this->query($query); |
454 | 454 | if (!$records || !is_array($records) || (count($records) !== 1)) { |
455 | 455 | return false; |
456 | 456 | } |
457 | 457 | |
458 | - $entityID = $records[0]['id']; |
|
458 | + $entityID = $records[ 0 ][ 'id' ]; |
|
459 | 459 | $entityIDParts = explode('x', $entityID, 2); |
460 | 460 | return (is_array($entityIDParts) && count($entityIDParts) === 2) |
461 | - ? $entityIDParts[1] |
|
461 | + ? $entityIDParts[ 1 ] |
|
462 | 462 | : -1; |
463 | 463 | } |
464 | 464 | |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | $this->checkLogin(); |
475 | 475 | |
476 | 476 | // Assign record to logged in user if not specified |
477 | - if (!isset($params['assigned_user_id'])) { |
|
478 | - $params['assigned_user_id'] = $this->userID; |
|
477 | + if (!isset($params[ 'assigned_user_id' ])) { |
|
478 | + $params[ 'assigned_user_id' ] = $this->userID; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | $postdata = [ |
@@ -500,19 +500,19 @@ discard block |
||
500 | 500 | $this->checkLogin(); |
501 | 501 | |
502 | 502 | // Assign record to logged in user if not specified |
503 | - if (!isset($params['assigned_user_id'])) { |
|
504 | - $params['assigned_user_id'] = $this->userID; |
|
503 | + if (!isset($params[ 'assigned_user_id' ])) { |
|
504 | + $params[ 'assigned_user_id' ] = $this->userID; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | // TODO implement the case when no ID is given |
508 | 508 | if (array_key_exists('id', $params)) { |
509 | - $data = $this->entityRetrieveByID($moduleName, $params['id']); |
|
509 | + $data = $this->entityRetrieveByID($moduleName, $params[ 'id' ]); |
|
510 | 510 | if ($data !== false && is_array($data)) { |
511 | - $entityID = $data['id']; |
|
511 | + $entityID = $data[ 'id' ]; |
|
512 | 512 | $params = array_merge( |
513 | - $data, // needed to provide mandatory field values |
|
514 | - $params, // updated data override |
|
515 | - ['id'=>$entityID] // fixing id, might be useful when non <moduleid>x<id> one was specified |
|
513 | + $data, // needed to provide mandatory field values |
|
514 | + $params, // updated data override |
|
515 | + [ 'id'=>$entityID ] // fixing id, might be useful when non <moduleid>x<id> one was specified |
|
516 | 516 | ); |
517 | 517 | } |
518 | 518 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | ]; |
573 | 573 | |
574 | 574 | if (!empty($moduleName)) { |
575 | - $requestData['elementType'] = $moduleName; |
|
575 | + $requestData[ 'elementType' ] = $moduleName; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | return $this->sendHttpRequest($requestData, true); |