Completed
Push — 3.2.3 ( dc6ae9...b87a24 )
by
unknown
01:36
created
src/Log/ZohoSyncSQLLogger.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use Doctrine\DBAL\Connection;
5 5
 use Doctrine\DBAL\Logging\SQLLogger;
6
-use Doctrine\DBAL\SQLParserUtils;
7 6
 use function PHPSTORM_META\type;
8 7
 use Psr\Log\LoggerInterface;
9 8
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
         $query = null;
58 58
         if ($params && $this->authorizedSQLWithParams) {
59 59
             $this->logger->debug($sql.' -- Params : {params} - Types : {types}', ['params' => json_encode($params), 'types' => json_encode($types)]);
60
-        } elseif($this->authorizedSQLWithoutParams) {
60
+        } elseif ($this->authorizedSQLWithoutParams) {
61 61
             $this->logger->debug($sql);
62 62
         }
63 63
     }
Please login to merge, or discard this patch.
src/ZohoDatabasePusher.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use Wabel\Zoho\CRM\AbstractZohoDao;
9 9
 use Wabel\Zoho\CRM\Service\EntitiesGeneratorService;
10 10
 use Wabel\Zoho\CRM\ZohoBeanInterface;
11
-use zcrmsdk\crm\api\response\EntityResponse;
12 11
 
13 12
 /**
14 13
  * Description of ZohoDatabasePusher.
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -288,6 +288,9 @@  discard block
 block discarded – undo
288 288
         }
289 289
     }
290 290
     
291
+    /**
292
+     * @param string $needle
293
+     */
291 294
     private function endsWith($haystack, $needle) {
292 295
         return substr_compare($haystack, $needle, -strlen($needle)) === 0;
293 296
     }
@@ -322,7 +325,6 @@  discard block
 block discarded – undo
322 325
      * Insert data to bean in order to update zoho records.
323 326
      *
324 327
      * @param ZohoBeanInterface $zohoBean
325
-     * @param array $fieldsMatching
326 328
      * @param type $columnName
327 329
      * @param type $valueDb
328 330
      */
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix);
69 69
         if ($update) {
70
-            return (int)$this->connection->executeQuery('SELECT COUNT(DISTINCT uid) AS nb FROM `local_update` WHERE table_name LIKE :tableName AND error IS NULL', ['tableName' => $tableName])->fetchColumn();
70
+            return (int) $this->connection->executeQuery('SELECT COUNT(DISTINCT uid) AS nb FROM `local_update` WHERE table_name LIKE :tableName AND error IS NULL', ['tableName' => $tableName])->fetchColumn();
71 71
         }
72
-        return (int)$this->connection->executeQuery('SELECT COUNT(uid) AS nb FROM `local_insert` WHERE table_name LIKE :tableName AND error IS NULL', ['tableName' => $tableName])->fetchColumn();
72
+        return (int) $this->connection->executeQuery('SELECT COUNT(uid) AS nb FROM `local_insert` WHERE table_name LIKE :tableName AND error IS NULL', ['tableName' => $tableName])->fetchColumn();
73 73
     }
74 74
 
75 75
     /**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         $localTable = $update ? 'local_update' : 'local_insert';
83 83
         $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix);
84 84
         $countToPush = $this->countElementInTable($zohoDao, $update);
85
-        $this->logger->notice($countToPush . ' records to ' . ($update ? 'update' : 'insert') . ' into Zoho for module ' . $zohoDao->getPluralModuleName());
85
+        $this->logger->notice($countToPush.' records to '.($update ? 'update' : 'insert').' into Zoho for module '.$zohoDao->getPluralModuleName());
86 86
         if ($countToPush) {
87 87
             do {
88 88
                 $rowsDeleted = [];
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
                         ]
256 256
                     );
257 257
                 } else {
258
-                    $countResult = (int)$this->connection->fetchColumn('select count(id) from ' . $tableName . ' where id = :id', ['id' => $zohoBean->getZohoId()]);
258
+                    $countResult = (int) $this->connection->fetchColumn('select count(id) from '.$tableName.' where id = :id', ['id' => $zohoBean->getZohoId()]);
259 259
                     //If the sent data were duplicates Zoho can merged so we need to check if the Zoho ID already exist.
260 260
                     if ($countResult === 0) {
261 261
                         // ID not exist we can update the new row with the Zoho ID
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
                 $value = \DateTime::createFromFormat('Y-m-d H:i:s', $value) ?: null;
362 362
                 break;
363 363
             case 'boolean' :
364
-                $value = (bool)$value;
364
+                $value = (bool) $value;
365 365
                 break;
366 366
             case 'percent' :
367
-                $value = (int)$value;
367
+                $value = (int) $value;
368 368
                 break;
369 369
             case 'double' :
370
-                $value = (float)$value;
370
+                $value = (float) $value;
371 371
                 break;
372 372
             case 'multiselectlookup':
373 373
             case 'multiuserlookup':
Please login to merge, or discard this patch.
src/LocalChangesTracker.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     public function createUuidInsertTrigger(Table $table)
96 96
     {
97 97
         $triggerName = sprintf('TRG_%s_SETUUIDBEFOREINSERT', $table->getName());
98
-        $this->logger->info('Creating ' . $triggerName . ' trigger for table ' . $table->getName() . '...');
98
+        $this->logger->info('Creating '.$triggerName.' trigger for table '.$table->getName().'...');
99 99
 
100 100
         //Fix - temporary MySQL 5.7 strict mode
101 101
         $sql = sprintf(
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     public function createInsertTrigger(Table $table)
125 125
     {
126 126
         $triggerName = sprintf('TRG_%s_ONINSERT', $table->getName());
127
-        $this->logger->info('Creating ' . $triggerName . ' trigger for table ' . $table->getName() . '...');
127
+        $this->logger->info('Creating '.$triggerName.' trigger for table '.$table->getName().'...');
128 128
 
129 129
         $tableNameQuoted = $this->connection->quote($table->getName());
130 130
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     public function createDeleteTrigger(Table $table)
152 152
     {
153 153
         $triggerName = sprintf('TRG_%s_ONDELETE', $table->getName());
154
-        $this->logger->info('Creating ' . $triggerName . ' trigger for table ' . $table->getName() . '...');
154
+        $this->logger->info('Creating '.$triggerName.' trigger for table '.$table->getName().'...');
155 155
 
156 156
         $tableNameQuoted = $this->connection->quote($table->getName());
157 157
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     public function createUpdateTrigger(Table $table)
179 179
     {
180 180
         $triggerName = sprintf('TRG_%s_ONUPDATE', $table->getName());
181
-        $this->logger->info('Creating ' . $triggerName . ' trigger for table ' . $table->getName() . '...');
181
+        $this->logger->info('Creating '.$triggerName.' trigger for table '.$table->getName().'...');
182 182
 
183 183
         $innerCode = '';
184 184
 
Please login to merge, or discard this patch.
src/ZohoDatabaseModelSync.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         $tableName = ZohoDatabaseHelper::getTableName($dao, $this->prefix);
89
-        $this->logger->notice('Synchronizing DB Model for ' . $tableName . '...');
89
+        $this->logger->notice('Synchronizing DB Model for '.$tableName.'...');
90 90
 
91 91
         $schema = new Schema();
92 92
         $table = $schema->createTable($tableName);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     continue 2;
178 178
                     break;
179 179
                 default:
180
-                    throw new \RuntimeException('Unknown type "' . $field->getType() . '"');
180
+                    throw new \RuntimeException('Unknown type "'.$field->getType().'"');
181 181
             }
182 182
 
183 183
             // For MySQL, the maximum row size is 65535 bytes.
Please login to merge, or discard this patch.
src/ZohoSyncDatabaseCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             if ($input->getOption('log-path') && $input->getOption('clear-logs')) {
142 142
                 $this->logger->notice('Clearing logs...');
143 143
                 $path = $input->getOption('log-path');
144
-                $logFile = $path . '/ZCRMClientLibrary.log';
144
+                $logFile = $path.'/ZCRMClientLibrary.log';
145 145
                 if (file_exists($logFile)) {
146 146
                     if (is_writable($logFile)) {
147 147
                         if (file_put_contents($logFile, '') === false) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
             if ($input->getOption('log-path') && $input->getOption('dump-logs')) {
186 186
                 $this->logger->info('Dumping logs...');
187 187
                 $path = $input->getOption('log-path');
188
-                $logFile = $path . '/ZCRMClientLibrary.log';
188
+                $logFile = $path.'/ZCRMClientLibrary.log';
189 189
                 if (file_exists($logFile)) {
190 190
                     if (is_readable($logFile)) {
191 191
                         $this->logger->info(file_get_contents($logFile));
Please login to merge, or discard this patch.
src/ZohoDatabaseCopier.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $users = $this->zohoUserService->getUsers();
74 74
         $tableName = 'users';
75
-        $this->logger->info('Fetched ' . count($users) . ' records for table ' . $tableName);
75
+        $this->logger->info('Fetched '.count($users).' records for table '.$tableName);
76 76
 
77 77
         $table = $this->connection->getSchemaManager()->createSchema()->getTable($tableName);
78 78
 
79
-        $select = $this->connection->prepare('SELECT * FROM ' . $tableName . ' WHERE id = :id');
79
+        $select = $this->connection->prepare('SELECT * FROM '.$tableName.' WHERE id = :id');
80 80
 
81 81
         $this->connection->beginTransaction();
82 82
         foreach ($users as $user) {
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                                     $lastPageInConfig = '1';
194 194
                                 }
195 195
                                 $lastActivityTime = new \DateTime($lastDateInConfig, new \DateTimeZone($dao->getZohoClient()->getTimezone()));
196
-                                $recordsPage = (int)$lastPageInConfig;
196
+                                $recordsPage = (int) $lastPageInConfig;
197 197
                             } else {
198 198
                                 $findDateByModifiedTime = true;
199 199
                             }
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
                                 $lastActivityTime = new \DateTime($modifiedSince);
207 207
                             } else {
208 208
                                 if ($tableHasColumnModifiedTime) {
209
-                                    $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM ' . $tableName);
209
+                                    $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName);
210 210
                                 }
211 211
                                 if (!$lastActivityTime && $tableHasColumnCreatedTime) {
212
-                                    $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM ' . $tableName);
212
+                                    $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName);
213 213
                                 }
214 214
 
215 215
                                 if ($lastActivityTime !== null) {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                         if ($zohoSyncConfigTableExists) {
249 249
                             $lastDate = $lastActivityTime ? $lastActivityTime->format('Y-m-d H:i:s') : date('Y-m-d H:i:s', 0);
250 250
                             $this->upsertZohoConfig('FETCH_RECORDS_MODIFIED_SINCE__DATE', $tableName, $lastDate);
251
-                            $this->upsertZohoConfig('FETCH_RECORDS_MODIFIED_SINCE__PAGE', $tableName, (string)$recordsPage);
251
+                            $this->upsertZohoConfig('FETCH_RECORDS_MODIFIED_SINCE__PAGE', $tableName, (string) $recordsPage);
252 252
                         }
253 253
 
254 254
                         $recordsPaginationLastTime = $lastActivityTime;
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
                         if ($zohoSyncConfigTableExists) {
258 258
                             $latestDateToSave = $currentDateTime->format('Y-m-d H:i:s');
259 259
                             if ($tableHasColumnModifiedTime) {
260
-                                $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM ' . $tableName);
260
+                                $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName);
261 261
                             }
262 262
                             if (!$latestDateToSave && $tableHasColumnCreatedTime) {
263
-                                $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM ' . $tableName);
263
+                                $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName);
264 264
                             }
265 265
                             if (!$latestDateToSave) {
266 266
                                 $latestDateToSave = $currentDateTime->format('Y-m-d H:i:s');
@@ -270,26 +270,26 @@  discard block
 block discarded – undo
270 270
                         }
271 271
                     }
272 272
                     $totalRecords = count($records);
273
-                    $this->logger->debug($totalRecords . ' records fetched.');
273
+                    $this->logger->debug($totalRecords.' records fetched.');
274 274
                     $deletedRecords = [];
275 275
                     $totalRecordsDeleted = 0;
276 276
                     if (($recordsPage - 1) === 1) {
277 277
                         $this->logger->notice(sprintf('Fetching the records to delete for module %s...', $dao->getPluralModuleName()));
278 278
                         $deletedRecords = $dao->getDeletedRecordIds($lastActivityTime);
279 279
                         $totalRecordsDeleted = count($deletedRecords);
280
-                        $this->logger->debug($totalRecordsDeleted . ' records fetched.');
280
+                        $this->logger->debug($totalRecordsDeleted.' records fetched.');
281 281
                     }
282 282
                 } else {
283 283
                     $this->logger->info(sprintf('Full copy started for module %s', $dao->getPluralModuleName()));
284 284
                     $this->logger->notice(sprintf('Fetching the records to insert/update for module ...%s', $dao->getPluralModuleName()));
285 285
                     $records = $dao->getRecords();
286 286
                     $totalRecords = count($records);
287
-                    $this->logger->debug($totalRecords . ' records fetched.');
287
+                    $this->logger->debug($totalRecords.' records fetched.');
288 288
                     $deletedRecords = [];
289 289
                     $stopAndhasMoreResults = false;
290 290
                 }
291 291
             } catch (ZCRMException $exception) {
292
-                $this->logger->error('Error when getting records for module ' . $dao->getPluralModuleName() . ': ' . $exception->getMessage(), [
292
+                $this->logger->error('Error when getting records for module '.$dao->getPluralModuleName().': '.$exception->getMessage(), [
293 293
                     'exception' => $exception
294 294
                 ]);
295 295
                 if ($throwErrors) {
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
             }
300 300
             $this->logger->info(sprintf('Inserting/updating %s records into table %s...', $totalRecords, $tableName));
301 301
 
302
-            $select = $this->connection->prepare('SELECT * FROM ' . $tableName . ' WHERE id = :id');
302
+            $select = $this->connection->prepare('SELECT * FROM '.$tableName.' WHERE id = :id');
303 303
 
304 304
             $this->connection->beginTransaction();
305 305
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
             }
381 381
 
382 382
             $this->logger->info(sprintf('Deleting %d records from table %s...', $totalRecordsDeleted, $tableName));
383
-            $sqlStatementUid = 'select uid from ' . $this->connection->quoteIdentifier($tableName) . ' where id = :id';
383
+            $sqlStatementUid = 'select uid from '.$this->connection->quoteIdentifier($tableName).' where id = :id';
384 384
             $processedRecords = 0;
385 385
             $logOffset = $totalRecordsDeleted >= 500 ? 100 : 50;
386 386
             foreach ($deletedRecords as $deletedRecord) {
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
                 if ($zohoSyncConfigTableExists) {
413 413
                     $latestDateToSave = $currentDateTime->format('Y-m-d H:i:s');
414 414
                     if ($tableHasColumnModifiedTime) {
415
-                        $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM ' . $tableName);
415
+                        $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName);
416 416
                     }
417 417
                     if (!$latestDateToSave && $tableHasColumnCreatedTime) {
418
-                        $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM ' . $tableName);
418
+                        $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName);
419 419
                     }
420 420
                     if (!$latestDateToSave) {
421 421
                         $latestDateToSave = $currentDateTime->format('Y-m-d H:i:s');
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
         $table = $this->connection->getSchemaManager()->createSchema()->getTable($tableName);
440 440
         $apiModuleName = $dao->getPluralModuleName();
441 441
 
442
-        $this->logger->notice('Starting bulk fetch for module ' . $apiModuleName . '...');
442
+        $this->logger->notice('Starting bulk fetch for module '.$apiModuleName.'...');
443 443
 
444 444
         $zohoClient = new ZohoClient([
445 445
             'client_id' => ZOHO_CRM_CLIENT_ID,
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
             $oauthToken = $zohoClient->getZohoOAuthClient()->getAccessToken(ZOHO_CRM_CLIENT_CURRENT_USER_EMAIL);
459 459
 
460 460
             // Step 1: Create a bulk read job
461
-            $this->logger->info('Creating read job for module ' . $apiModuleName . ' and page ' . $page . '...');
462
-            $response = $client->request('POST', 'https://' . (ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www') . '.zohoapis.com/crm/bulk/v2/read', [
461
+            $this->logger->info('Creating read job for module '.$apiModuleName.' and page '.$page.'...');
462
+            $response = $client->request('POST', 'https://'.(ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www').'.zohoapis.com/crm/bulk/v2/read', [
463 463
                 'http_errors' => false,
464 464
                 'headers' => [
465
-                    'Authorization' => 'Zoho-oauthtoken ' . $oauthToken
465
+                    'Authorization' => 'Zoho-oauthtoken '.$oauthToken
466 466
                 ],
467 467
                 'json' => [
468 468
                     'query' => [
@@ -480,23 +480,23 @@  discard block
 block discarded – undo
480 480
 
481 481
                 // We don't care about the job status right now, it will be checked later
482 482
             } else {
483
-                $this->logger->error('Cannot create bulk read query for module ' . $apiModuleName . ': status: ' . $response->getStatusCode() . '. Status: ' . $response->getBody()->getContents());
483
+                $this->logger->error('Cannot create bulk read query for module '.$apiModuleName.': status: '.$response->getStatusCode().'. Status: '.$response->getBody()->getContents());
484 484
                 break;
485 485
             }
486 486
 
487 487
             if ($jobId === null) {
488
-                $this->logger->error('JobID cannot be null. json:' . $resultStr);
488
+                $this->logger->error('JobID cannot be null. json:'.$resultStr);
489 489
                 break;
490 490
             }
491 491
 
492 492
             // Step 2: Check job status
493 493
             $jobDetails = null;
494 494
             while (true) {
495
-                $this->logger->info('Checking job ' . $jobId . ' status for module ' . $apiModuleName . ' and page ' . $page . '...');
496
-                $response = $client->request('GET', 'https://' . (ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www') . '.zohoapis.com/crm/bulk/v2/read/' . $jobId, [
495
+                $this->logger->info('Checking job '.$jobId.' status for module '.$apiModuleName.' and page '.$page.'...');
496
+                $response = $client->request('GET', 'https://'.(ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www').'.zohoapis.com/crm/bulk/v2/read/'.$jobId, [
497 497
                     'http_errors' => false,
498 498
                     'headers' => [
499
-                        'Authorization' => 'Zoho-oauthtoken ' . $oauthToken
499
+                        'Authorization' => 'Zoho-oauthtoken '.$oauthToken
500 500
                     ]
501 501
                 ]);
502 502
                 if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
@@ -514,15 +514,15 @@  discard block
 block discarded – undo
514 514
                             $jobDetails = $json;
515 515
                             break;
516 516
                         } else {
517
-                            $this->logger->info('Unsupported job status: ' . $resultStr);
517
+                            $this->logger->info('Unsupported job status: '.$resultStr);
518 518
                             break;
519 519
                         }
520 520
                     } else {
521
-                        $this->logger->error('Unsupported response: ' . $resultStr);
521
+                        $this->logger->error('Unsupported response: '.$resultStr);
522 522
                         break;
523 523
                     }
524 524
                 } else {
525
-                    $this->logger->error('Cannot get bulk job status query for module ' . $apiModuleName . ': status: ' . $response->getStatusCode() . '. Status: ' . $response->getBody()->getContents());
525
+                    $this->logger->error('Cannot get bulk job status query for module '.$apiModuleName.': status: '.$response->getStatusCode().'. Status: '.$response->getBody()->getContents());
526 526
                     break;
527 527
                 }
528 528
                 sleep(15);
@@ -530,31 +530,31 @@  discard block
 block discarded – undo
530 530
 
531 531
             // Step 3: Download the result
532 532
             if ($jobDetails === null) {
533
-                $this->logger->error('JobDetails cannot be empty. json:' . $resultStr);
533
+                $this->logger->error('JobDetails cannot be empty. json:'.$resultStr);
534 534
                 break;
535 535
             }
536 536
             $this->logger->debug(json_encode($jobDetails));
537
-            $this->logger->info('Downloading zip file for module ' . $apiModuleName . ' and page ' . $page . '...');
538
-            $jobZipFile = '/tmp/job_' . $dao->getZCRMModule()->getAPIName() . '_' . $jobDetails['data'][0]['id'] . '.zip';
537
+            $this->logger->info('Downloading zip file for module '.$apiModuleName.' and page '.$page.'...');
538
+            $jobZipFile = '/tmp/job_'.$dao->getZCRMModule()->getAPIName().'_'.$jobDetails['data'][0]['id'].'.zip';
539 539
             $jobCsvPath = '/tmp/job_extract';
540
-            $jobCsvFile = '/tmp/job_extract/' . $jobDetails['data'][0]['id'] . '.csv';
540
+            $jobCsvFile = '/tmp/job_extract/'.$jobDetails['data'][0]['id'].'.csv';
541 541
             $canProcessCsv = false;
542 542
 
543
-            $response = $client->request('GET', 'https://' . (ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www') . '.zohoapis.com/crm/bulk/v2/read/' . $jobId . '/result', [
543
+            $response = $client->request('GET', 'https://'.(ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www').'.zohoapis.com/crm/bulk/v2/read/'.$jobId.'/result', [
544 544
                 'http_errors' => false,
545 545
                 'headers' => [
546
-                    'Authorization' => 'Zoho-oauthtoken ' . $oauthToken
546
+                    'Authorization' => 'Zoho-oauthtoken '.$oauthToken
547 547
                 ],
548 548
                 'sink' => $jobZipFile
549 549
             ]);
550 550
             if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
551
-                $this->logger->info('Extracting ' . $jobZipFile . ' file for module ' . $apiModuleName . ' and page ' . $page . '...');
551
+                $this->logger->info('Extracting '.$jobZipFile.' file for module '.$apiModuleName.' and page '.$page.'...');
552 552
                 $zip = new ZipArchive();
553 553
                 $res = $zip->open($jobZipFile);
554 554
                 if ($res === TRUE) {
555 555
                     $zip->extractTo($jobCsvPath);
556 556
                     $zip->close();
557
-                    $this->logger->info('File extracted in ' . $jobCsvFile);
557
+                    $this->logger->info('File extracted in '.$jobCsvFile);
558 558
                     $canProcessCsv = true;
559 559
                 } else {
560 560
                     switch ($res) {
@@ -586,11 +586,11 @@  discard block
 block discarded – undo
586 586
                             $zipErrorMessage = "Unknow (Code $res)";
587 587
                             break;
588 588
                     }
589
-                    $this->logger->error('Error when extracting zip file: ' . $zipErrorMessage);
589
+                    $this->logger->error('Error when extracting zip file: '.$zipErrorMessage);
590 590
                     break;
591 591
                 }
592 592
             } else {
593
-                $this->logger->error('Cannot download results for module ' . $apiModuleName . ': status: ' . $response->getStatusCode() . '. Status: ' . $response->getBody()->getContents());
593
+                $this->logger->error('Cannot download results for module '.$apiModuleName.': status: '.$response->getStatusCode().'. Status: '.$response->getBody()->getContents());
594 594
                 break;
595 595
             }
596 596
 
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
             $this->logger->info('Saving records to db...');
612 612
             $nbRecords = $jobDetails['data'][0]['result']['count'];
613 613
             $whenToLog = ceil($nbRecords / 100);
614
-            $this->logger->info($nbRecords . ' records to save');
614
+            $this->logger->info($nbRecords.' records to save');
615 615
             $nbSaved = 0;
616 616
             $handle = fopen($jobCsvFile, 'r');
617 617
             $fields = [];
@@ -629,30 +629,30 @@  discard block
 block discarded – undo
629 629
                             $recordDataToInsert[$decodedColumnName] = $value === '' ? null : $value;
630 630
                         } else {
631 631
                             if ($columnName === 'Owner' || $columnName === 'Created_By' || $columnName === 'Modified_By') {
632
-                                $recordDataToInsert[$decodedColumnName . '_OwnerID'] = $value === '' ? null : $value;
633
-                                $recordDataToInsert[$decodedColumnName . '_OwnerName'] = $users[$value] ?? null;
634
-                            } else if ($table->hasColumn($decodedColumnName . '_ID')) {
635
-                                $recordDataToInsert[$decodedColumnName . '_ID'] = $value === '' ? null : $value;
632
+                                $recordDataToInsert[$decodedColumnName.'_OwnerID'] = $value === '' ? null : $value;
633
+                                $recordDataToInsert[$decodedColumnName.'_OwnerName'] = $users[$value] ?? null;
634
+                            } else if ($table->hasColumn($decodedColumnName.'_ID')) {
635
+                                $recordDataToInsert[$decodedColumnName.'_ID'] = $value === '' ? null : $value;
636 636
                             }
637 637
                         }
638 638
                     }
639 639
                     $this->connection->insert($tableName, $recordDataToInsert);
640 640
                     ++$nbSaved;
641 641
                     if (($nbSaved % $whenToLog) === 0) {
642
-                        $this->logger->info($nbSaved . '/' . $nbRecords . ' records processed');
642
+                        $this->logger->info($nbSaved.'/'.$nbRecords.' records processed');
643 643
                     }
644 644
                 }
645
-                $this->logger->info($nbSaved . ' records saved for module ' . $apiModuleName . ' and page ' . $page);
645
+                $this->logger->info($nbSaved.' records saved for module '.$apiModuleName.' and page '.$page);
646 646
                 fclose($handle);
647 647
             }
648 648
 
649 649
             // Step 5: Check if there is more results
650 650
             $hasMoreRecords = $jobDetails['data'][0]['result']['more_records'];
651 651
             if (!$hasMoreRecords) {
652
-                $this->logger->info('No more records for the module ' . $apiModuleName);
652
+                $this->logger->info('No more records for the module '.$apiModuleName);
653 653
                 break;
654 654
             }
655
-            $this->logger->info('More records to fetch for the module ' . $apiModuleName);
655
+            $this->logger->info('More records to fetch for the module '.$apiModuleName);
656 656
             ++$page;
657 657
         }
658 658
     }
Please login to merge, or discard this patch.