@@ -268,6 +268,7 @@  | 
                                                    ||
| 268 | 268 | * @access private  | 
                                                        
| 269 | 269 | * @static  | 
                                                        
| 270 | 270 | * @param string Base URL of vTiger CRM  | 
                                                        
| 271 | + * @param string $baseUrl  | 
                                                        |
| 271 | 272 | * @return boolean Returns cleaned and fixed vTiger URL  | 
                                                        
| 272 | 273 | */  | 
                                                        
| 273 | 274 | private static function fixVtigerBaseUrl($baseUrl)  | 
                                                        
@@ -100,7 +100,7 @@ discard block  | 
                                                    ||
| 100 | 100 | $postdata = [  | 
                                                        
| 101 | 101 | 'operation' => 'login',  | 
                                                        
| 102 | 102 | 'username' => $username,  | 
                                                        
| 103 | - 'accessKey' => md5($this->serviceToken . $accessKey)  | 
                                                        |
| 103 | + 'accessKey' => md5($this->serviceToken.$accessKey)  | 
                                                        |
| 104 | 104 | ];  | 
                                                        
| 105 | 105 | |
| 106 | 106 | $result = $this->sendHttpRequest($postdata);  | 
                                                        
@@ -113,12 +113,12 @@ discard block  | 
                                                    ||
| 113 | 113 | $this->accessKey = $accessKey;  | 
                                                        
| 114 | 114 | |
| 115 | 115 | // Session data  | 
                                                        
| 116 | - $this->sessionName = $result['sessionName'];  | 
                                                        |
| 117 | - $this->userID = $result['userId'];  | 
                                                        |
| 116 | + $this->sessionName = $result[ 'sessionName' ];  | 
                                                        |
| 117 | + $this->userID = $result[ 'userId' ];  | 
                                                        |
| 118 | 118 | |
| 119 | 119 | // Vtiger CRM and WebServices API version  | 
                                                        
| 120 | - $this->vtigerApiVersion = $result['version'];  | 
                                                        |
| 121 | - $this->vtigerVersion = $result['vtigerVersion'];  | 
                                                        |
| 120 | + $this->vtigerApiVersion = $result[ 'version' ];  | 
                                                        |
| 121 | + $this->vtigerVersion = $result[ 'vtigerVersion' ];  | 
                                                        |
| 122 | 122 | |
| 123 | 123 | return true;  | 
                                                        
| 124 | 124 | }  | 
                                                        
@@ -150,8 +150,8 @@ discard block  | 
                                                    ||
| 150 | 150 | }  | 
                                                        
| 151 | 151 | |
| 152 | 152 |          $this->accessKey = array_key_exists('accesskey', $result) | 
                                                        
| 153 | - ? $result['accesskey']  | 
                                                        |
| 154 | - : $result[0];  | 
                                                        |
| 153 | + ? $result[ 'accesskey' ]  | 
                                                        |
| 154 | + : $result[ 0 ];  | 
                                                        |
| 155 | 155 | |
| 156 | 156 | return $this->login($username, $accessKey);  | 
                                                        
| 157 | 157 | }  | 
                                                        
@@ -170,13 +170,13 @@ discard block  | 
                                                    ||
| 170 | 170 | ];  | 
                                                        
| 171 | 171 | $result = $this->sendHttpRequest($getdata, 'GET');  | 
                                                        
| 172 | 172 | |
| 173 | -        if (!is_array($result) || !isset($result['token'])) { | 
                                                        |
| 173 | +        if (!is_array($result) || !isset($result[ 'token' ])) { | 
                                                        |
| 174 | 174 | return false;  | 
                                                        
| 175 | 175 | }  | 
                                                        
| 176 | 176 | |
| 177 | 177 | # $this->serviceServerTime = $result['serverTime'];  | 
                                                        
| 178 | - $this->serviceExpireTime = $result['expireTime'];  | 
                                                        |
| 179 | - $this->serviceToken = $result['token'];  | 
                                                        |
| 178 | + $this->serviceExpireTime = $result[ 'expireTime' ];  | 
                                                        |
| 179 | + $this->serviceToken = $result[ 'token' ];  | 
                                                        |
| 180 | 180 | |
| 181 | 181 | return true;  | 
                                                        
| 182 | 182 | }  | 
                                                        
@@ -224,30 +224,30 @@ discard block  | 
                                                    ||
| 224 | 224 | */  | 
                                                        
| 225 | 225 | public function sendHttpRequest(array $requestData, $method = 'POST')  | 
                                                        
| 226 | 226 |      { | 
                                                        
| 227 | -        if (!isset($requestData['operation'])) { | 
                                                        |
| 227 | +        if (!isset($requestData[ 'operation' ])) { | 
                                                        |
| 228 | 228 |              throw new WSException('Request data must contain the name of the operation!'); | 
                                                        
| 229 | 229 | }  | 
                                                        
| 230 | 230 | |
| 231 | - $requestData['sessionName'] = $this->sessionName;  | 
                                                        |
| 231 | + $requestData[ 'sessionName' ] = $this->sessionName;  | 
                                                        |
| 232 | 232 | |
| 233 | 233 | // Perform re-login if required.  | 
                                                        
| 234 | -        if ('getchallenge' !== $requestData['operation'] && time() > $this->serviceExpireTime) { | 
                                                        |
| 234 | +        if ('getchallenge' !== $requestData[ 'operation' ] && time() > $this->serviceExpireTime) { | 
                                                        |
| 235 | 235 | $this->login($this->userName, $this->accessKey);  | 
                                                        
| 236 | 236 | }  | 
                                                        
| 237 | 237 | |
| 238 | 238 |          try { | 
                                                        
| 239 | 239 |              switch ($method) { | 
                                                        
| 240 | 240 | case 'GET':  | 
                                                        
| 241 | - $response = $this->httpClient->get($this->serviceBaseURL, ['query' => $requestData]);  | 
                                                        |
| 241 | + $response = $this->httpClient->get($this->serviceBaseURL, [ 'query' => $requestData ]);  | 
                                                        |
| 242 | 242 | break;  | 
                                                        
| 243 | 243 | case 'POST':  | 
                                                        
| 244 | - $response = $this->httpClient->post($this->serviceBaseURL, ['form_params' => $requestData]);  | 
                                                        |
| 244 | + $response = $this->httpClient->post($this->serviceBaseURL, [ 'form_params' => $requestData ]);  | 
                                                        |
| 245 | 245 | break;  | 
                                                        
| 246 | 246 | default:  | 
                                                        
| 247 | 247 |                      throw new WSException("Unsupported request type {$method}"); | 
                                                        
| 248 | 248 | }  | 
                                                        
| 249 | 249 |          } catch (RequestException $ex) { | 
                                                        
| 250 | -            $urlFailed = $this->httpClient->getConfig('base_uri') . $this->serviceBaseURL; | 
                                                        |
| 250 | +            $urlFailed = $this->httpClient->getConfig('base_uri').$this->serviceBaseURL; | 
                                                        |
| 251 | 251 | throw new WSException(  | 
                                                        
| 252 | 252 |                  sprintf('Failed to execute %s call on "%s" URL', $method, $urlFailed), | 
                                                        
| 253 | 253 | 'FAILED_SENDING_REQUEST',  | 
                                                        
@@ -260,7 +260,7 @@ discard block  | 
                                                    ||
| 260 | 260 | |
| 261 | 261 | return (!is_array($jsonObj) || self::checkForError($jsonObj))  | 
                                                        
| 262 | 262 | ? null  | 
                                                        
| 263 | - : $jsonObj['result'];  | 
                                                        |
| 263 | + : $jsonObj[ 'result' ];  | 
                                                        |
| 264 | 264 | }  | 
                                                        
| 265 | 265 | |
| 266 | 266 | /**  | 
                                                        
@@ -275,7 +275,7 @@ discard block  | 
                                                    ||
| 275 | 275 |          if (!preg_match('/^https?:\/\//i', $baseUrl)) { | 
                                                        
| 276 | 276 |              $baseUrl = sprintf('http://%s', $baseUrl); | 
                                                        
| 277 | 277 | }  | 
                                                        
| 278 | -        if (strripos($baseUrl, '/') !== strlen($baseUrl)-1) { | 
                                                        |
| 278 | +        if (strripos($baseUrl, '/') !== strlen($baseUrl) - 1) { | 
                                                        |
| 279 | 279 | $baseUrl .= '/';  | 
                                                        
| 280 | 280 | }  | 
                                                        
| 281 | 281 | return $baseUrl;  | 
                                                        
@@ -290,15 +290,15 @@ discard block  | 
                                                    ||
| 290 | 290 | */  | 
                                                        
| 291 | 291 | private static function checkForError(array $jsonResult)  | 
                                                        
| 292 | 292 |      { | 
                                                        
| 293 | -        if (isset($jsonResult['success']) && (bool)$jsonResult['success'] === true) { | 
                                                        |
| 293 | +        if (isset($jsonResult[ 'success' ]) && (bool) $jsonResult[ 'success' ] === true) { | 
                                                        |
| 294 | 294 | return false;  | 
                                                        
| 295 | 295 | }  | 
                                                        
| 296 | 296 | |
| 297 | -        if (isset($jsonResult['error'])) { | 
                                                        |
| 298 | - $error = $jsonResult['error'];  | 
                                                        |
| 297 | +        if (isset($jsonResult[ 'error' ])) { | 
                                                        |
| 298 | + $error = $jsonResult[ 'error' ];  | 
                                                        |
| 299 | 299 | throw new WSException(  | 
                                                        
| 300 | - $error['message'],  | 
                                                        |
| 301 | - $error['code']  | 
                                                        |
| 300 | + $error[ 'message' ],  | 
                                                        |
| 301 | + $error[ 'code' ]  | 
                                                        |
| 302 | 302 | );  | 
                                                        
| 303 | 303 | }  | 
                                                        
| 304 | 304 | |
@@ -69,11 +69,11 @@ discard block  | 
                                                    ||
| 69 | 69 | }  | 
                                                        
| 70 | 70 | |
| 71 | 71 | /**  | 
                                                        
| 72 | - * Retrieve an external iterator  | 
                                                        |
| 73 | - * @access public  | 
                                                        |
| 74 | - * @link http://php.net/manual/en/iteratoraggregate.getiterator.php  | 
                                                        |
| 75 | - * @return \Traversable An instance of an object implementing \Traversable  | 
                                                        |
| 76 | - */  | 
                                                        |
| 72 | + * Retrieve an external iterator  | 
                                                        |
| 73 | + * @access public  | 
                                                        |
| 74 | + * @link http://php.net/manual/en/iteratoraggregate.getiterator.php  | 
                                                        |
| 75 | + * @return \Traversable An instance of an object implementing \Traversable  | 
                                                        |
| 76 | + */  | 
                                                        |
| 77 | 77 | public function getIterator()  | 
                                                        
| 78 | 78 |      { | 
                                                        
| 79 | 79 | $properties = $this->getAllProperties();  | 
                                                        
@@ -83,10 +83,10 @@ discard block  | 
                                                    ||
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
| 85 | 85 | /**  | 
                                                        
| 86 | - * Gets all the properties of the object  | 
                                                        |
| 87 | - * @access public  | 
                                                        |
| 88 | - * @return array Array of properties  | 
                                                        |
| 89 | - */  | 
                                                        |
| 86 | + * Gets all the properties of the object  | 
                                                        |
| 87 | + * @access public  | 
                                                        |
| 88 | + * @return array Array of properties  | 
                                                        |
| 89 | + */  | 
                                                        |
| 90 | 90 | private function getAllProperties()  | 
                                                        
| 91 | 91 |      { | 
                                                        
| 92 | 92 | $allProperties = get_object_vars($this);  | 
                                                        
@@ -65,7 +65,7 @@ discard block  | 
                                                    ||
| 65 | 65 | */  | 
                                                        
| 66 | 66 | public function __toString()  | 
                                                        
| 67 | 67 |      { | 
                                                        
| 68 | -        return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; | 
                                                        |
| 68 | +        return __CLASS__.": [{$this->code}]: {$this->message}\n"; | 
                                                        |
| 69 | 69 | }  | 
                                                        
| 70 | 70 | |
| 71 | 71 | /**  | 
                                                        
@@ -95,7 +95,7 @@ discard block  | 
                                                    ||
| 95 | 95 |              $fullNameComponents = explode("\0", $fullName); | 
                                                        
| 96 | 96 | $propertyName = array_pop($fullNameComponents);  | 
                                                        
| 97 | 97 |              if ($propertyName && isset($value)) { | 
                                                        
| 98 | - $properties[$propertyName] = $value;  | 
                                                        |
| 98 | + $properties[ $propertyName ] = $value;  | 
                                                        |
| 99 | 99 | }  | 
                                                        
| 100 | 100 | }  | 
                                                        
| 101 | 101 | |
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 | * @return array $select The list of fields to select (defaults to SQL-like '*' - all the fields)  | 
                                                        
| 61 | 61 | * @return boolean Entity data  | 
                                                        
| 62 | 62 | */  | 
                                                        
| 63 | - public function findOneByID($moduleName, $entityID, array $select = [])  | 
                                                        |
| 63 | + public function findOneByID($moduleName, $entityID, array $select = [ ])  | 
                                                        |
| 64 | 64 |      { | 
                                                        
| 65 | 65 | return $this->findOne($moduleName, [ 'id' => $entityID ], $select);  | 
                                                        
| 66 | 66 | }  | 
                                                        
@@ -72,13 +72,13 @@ discard block  | 
                                                    ||
| 72 | 72 | * @return array $select The list of fields to select (defaults to SQL-like '*' - all the fields)  | 
                                                        
| 73 | 73 | * @return integer The matching record  | 
                                                        
| 74 | 74 | */  | 
                                                        
| 75 | - public function findOne($moduleName, array $params, array $select = [])  | 
                                                        |
| 75 | + public function findOne($moduleName, array $params, array $select = [ ])  | 
                                                        |
| 76 | 76 |      { | 
                                                        
| 77 | 77 | $records = $this->findMany($moduleName, $params, $select, 1);  | 
                                                        
| 78 | -        if (false === $records || !isset($records[0])) { | 
                                                        |
| 78 | +        if (false === $records || !isset($records[ 0 ])) { | 
                                                        |
| 79 | 79 | return false;  | 
                                                        
| 80 | 80 | }  | 
                                                        
| 81 | - return $records[0];  | 
                                                        |
| 81 | + return $records[ 0 ];  | 
                                                        |
| 82 | 82 | }  | 
                                                        
| 83 | 83 | |
| 84 | 84 | /**  | 
                                                        
@@ -89,11 +89,11 @@ discard block  | 
                                                    ||
| 89 | 89 | */  | 
                                                        
| 90 | 90 | public function getID($moduleName, array $params)  | 
                                                        
| 91 | 91 |      { | 
                                                        
| 92 | - $record = $this->findOne($moduleName, $params, ['id']);  | 
                                                        |
| 93 | -        if (false === $record || !isset($record['id']) || empty($record['id'])) { | 
                                                        |
| 92 | + $record = $this->findOne($moduleName, $params, [ 'id' ]);  | 
                                                        |
| 93 | +        if (false === $record || !isset($record[ 'id' ]) || empty($record[ 'id' ])) { | 
                                                        |
| 94 | 94 | return false;  | 
                                                        
| 95 | 95 | }  | 
                                                        
| 96 | - return $record['id'];  | 
                                                        |
| 96 | + return $record[ 'id' ];  | 
                                                        |
| 97 | 97 | }  | 
                                                        
| 98 | 98 | |
| 99 | 99 | /**  | 
                                                        
@@ -107,7 +107,7 @@ discard block  | 
                                                    ||
| 107 | 107 | $entityID = $this->getID($moduleName, $params);  | 
                                                        
| 108 | 108 |          $entityIDParts = explode('x', $entityID, 2); | 
                                                        
| 109 | 109 | return (is_array($entityIDParts) && count($entityIDParts) === 2)  | 
                                                        
| 110 | - ? intval($entityIDParts[1])  | 
                                                        |
| 110 | + ? intval($entityIDParts[ 1 ])  | 
                                                        |
| 111 | 111 | : -1;  | 
                                                        
| 112 | 112 | }  | 
                                                        
| 113 | 113 | |
@@ -124,9 +124,9 @@ discard block  | 
                                                    ||
| 124 | 124 | }  | 
                                                        
| 125 | 125 | |
| 126 | 126 | // Assign record to logged in user if not specified  | 
                                                        
| 127 | -        if (!isset($params['assigned_user_id'])) { | 
                                                        |
| 127 | +        if (!isset($params[ 'assigned_user_id' ])) { | 
                                                        |
| 128 | 128 | $currentUser = $this->wsClient->getCurrentUser();  | 
                                                        
| 129 | - $params['assigned_user_id'] = $currentUser['id'];  | 
                                                        |
| 129 | + $params[ 'assigned_user_id' ] = $currentUser[ 'id' ];  | 
                                                        |
| 130 | 130 | }  | 
                                                        
| 131 | 131 | |
| 132 | 132 | $requestData = [  | 
                                                        
@@ -199,7 +199,7 @@ discard block  | 
                                                    ||
| 199 | 199 | * @return integer $limit limit the list of entries to N records (acts like LIMIT in SQL)  | 
                                                        
| 200 | 200 | * @return bool|array The array containing matching entries or false if nothing was found  | 
                                                        
| 201 | 201 | */  | 
                                                        
| 202 | - public function findMany($moduleName, array $params, array $select = [], $limit = 0)  | 
                                                        |
| 202 | + public function findMany($moduleName, array $params, array $select = [ ], $limit = 0)  | 
                                                        |
| 203 | 203 |      { | 
                                                        
| 204 | 204 |          if (!self::checkParams($params, 'be able to retrieve entity(ies)')) { | 
                                                        
| 205 | 205 | return false;  | 
                                                        
@@ -234,7 +234,7 @@ discard block  | 
                                                    ||
| 234 | 234 | ];  | 
                                                        
| 235 | 235 | |
| 236 | 236 |          if (!empty($moduleName)) { | 
                                                        
| 237 | - $requestData['elementType'] = $moduleName;  | 
                                                        |
| 237 | + $requestData[ 'elementType' ] = $moduleName;  | 
                                                        |
| 238 | 238 | }  | 
                                                        
| 239 | 239 | |
| 240 | 240 |          return $this->wsClient->invokeOperation('sync', $requestData, true); | 
                                                        
@@ -268,18 +268,18 @@ discard block  | 
                                                    ||
| 268 | 268 | * @return int $limit limit the list of entries to N records (acts like LIMIT in SQL)  | 
                                                        
| 269 | 269 | * @return string The query build out of the supplied parameters  | 
                                                        
| 270 | 270 | */  | 
                                                        
| 271 | - public static function getQueryString($moduleName, array $params, array $select = [], $limit = 0)  | 
                                                        |
| 271 | + public static function getQueryString($moduleName, array $params, array $select = [ ], $limit = 0)  | 
                                                        |
| 272 | 272 |      { | 
                                                        
| 273 | 273 | $criteria = array();  | 
                                                        
| 274 | -        $select=(empty($select)) ? '*' : implode(',', $select); | 
                                                        |
| 275 | -        $query=sprintf("SELECT %s FROM $moduleName WHERE ", $select); | 
                                                        |
| 274 | +        $select = (empty($select)) ? '*' : implode(',', $select); | 
                                                        |
| 275 | +        $query = sprintf("SELECT %s FROM $moduleName WHERE ", $select); | 
                                                        |
| 276 | 276 |          foreach ($params as $param => $value) { | 
                                                        
| 277 | -            $criteria[] = "{$param} LIKE '{$value}'"; | 
                                                        |
| 277 | +            $criteria[ ] = "{$param} LIKE '{$value}'"; | 
                                                        |
| 278 | 278 | }  | 
                                                        
| 279 | 279 | |
| 280 | -        $query.=implode(" AND ", $criteria); | 
                                                        |
| 280 | +        $query .= implode(" AND ", $criteria); | 
                                                        |
| 281 | 281 |          if (intval($limit) > 0) { | 
                                                        
| 282 | -            $query.=sprintf(" LIMIT %s", intval($limit)); | 
                                                        |
| 282 | +            $query .= sprintf(" LIMIT %s", intval($limit)); | 
                                                        |
| 283 | 283 | }  | 
                                                        
| 284 | 284 | return $query;  | 
                                                        
| 285 | 285 | }  |