Completed
Push — 3.2.3 ( 3b762a...590ac3 )
by
unknown
01:29
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.
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.
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -305,6 +305,9 @@  discard block
 block discarded – undo
305 305
         }
306 306
     }
307 307
 
308
+    /**
309
+     * @param string $needle
310
+     */
308 311
     private function endsWith($haystack, $needle)
309 312
     {
310 313
         return substr_compare($haystack, $needle, -strlen($needle)) === 0;
@@ -340,7 +343,6 @@  discard block
 block discarded – undo
340 343
      * Insert data to bean in order to update zoho records.
341 344
      *
342 345
      * @param ZohoBeanInterface $zohoBean
343
-     * @param array $fieldsMatching
344 346
      * @param type $columnName
345 347
      * @param type $valueDb
346 348
      */
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   +48 added lines, -48 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) {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                                     $lastPageInConfig = '1';
198 198
                                 }
199 199
                                 $lastActivityTime = new \DateTime($lastDateInConfig, new \DateTimeZone($dao->getZohoClient()->getTimezone()));
200
-                                $recordsPage = (int)$lastPageInConfig;
200
+                                $recordsPage = (int) $lastPageInConfig;
201 201
                             } else {
202 202
                                 $findDateByModifiedTime = true;
203 203
                             }
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
                                 $lastActivityTime = new \DateTime($modifiedSince);
211 211
                             } else {
212 212
                                 if ($tableHasColumnModifiedTime) {
213
-                                    $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM ' . $tableName);
213
+                                    $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName);
214 214
                                 }
215 215
                                 if (!$lastActivityTime && $tableHasColumnCreatedTime) {
216
-                                    $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM ' . $tableName);
216
+                                    $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName);
217 217
                                 }
218 218
 
219 219
                                 if ($lastActivityTime !== null) {
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                         if ($zohoSyncConfigTableExists) {
254 254
                             $lastDate = $lastActivityTime ? $lastActivityTime->format('Y-m-d H:i:s') : date('Y-m-d H:i:s', 0);
255 255
                             $this->upsertZohoConfig('FETCH_RECORDS_MODIFIED_SINCE__DATE', $tableName, $lastDate);
256
-                            $this->upsertZohoConfig('FETCH_RECORDS_MODIFIED_SINCE__PAGE', $tableName, (string)$recordsPage);
256
+                            $this->upsertZohoConfig('FETCH_RECORDS_MODIFIED_SINCE__PAGE', $tableName, (string) $recordsPage);
257 257
                         }
258 258
 
259 259
                         $recordsPaginationLastTime = $lastActivityTime;
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
                         if ($zohoSyncConfigTableExists) {
263 263
                             $latestDateToSave = $currentDateTime->format('Y-m-d H:i:s');
264 264
                             if ($tableHasColumnModifiedTime) {
265
-                                $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM ' . $tableName);
265
+                                $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName);
266 266
                             }
267 267
                             if (!$latestDateToSave && $tableHasColumnCreatedTime) {
268
-                                $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM ' . $tableName);
268
+                                $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName);
269 269
                             }
270 270
                             if (!$latestDateToSave) {
271 271
                                 $latestDateToSave = $currentDateTime->format('Y-m-d H:i:s');
@@ -275,26 +275,26 @@  discard block
 block discarded – undo
275 275
                         }
276 276
                     }
277 277
                     $totalRecords = count($records);
278
-                    $this->logger->debug($totalRecords . ' records fetched.');
278
+                    $this->logger->debug($totalRecords.' records fetched.');
279 279
                     $deletedRecords = [];
280 280
                     $totalRecordsDeleted = 0;
281 281
                     if (($recordsPage - 1) === 1) {
282 282
                         $this->logger->notice(sprintf('Fetching the records to delete for module %s...', $dao->getPluralModuleName()));
283 283
                         $deletedRecords = $dao->getDeletedRecordIds($lastActivityTime);
284 284
                         $totalRecordsDeleted = count($deletedRecords);
285
-                        $this->logger->debug($totalRecordsDeleted . ' records fetched.');
285
+                        $this->logger->debug($totalRecordsDeleted.' records fetched.');
286 286
                     }
287 287
                 } else {
288 288
                     $this->logger->info(sprintf('Full copy started for module %s', $dao->getPluralModuleName()));
289 289
                     $this->logger->notice(sprintf('Fetching the records to insert/update for module ...%s', $dao->getPluralModuleName()));
290 290
                     $records = $dao->getRecords();
291 291
                     $totalRecords = count($records);
292
-                    $this->logger->debug($totalRecords . ' records fetched.');
292
+                    $this->logger->debug($totalRecords.' records fetched.');
293 293
                     $deletedRecords = [];
294 294
                     $stopAndhasMoreResults = false;
295 295
                 }
296 296
             } catch (ZCRMException $exception) {
297
-                $this->logger->error('Error when getting records for module ' . $dao->getPluralModuleName() . ': ' . $exception->getMessage(), [
297
+                $this->logger->error('Error when getting records for module '.$dao->getPluralModuleName().': '.$exception->getMessage(), [
298 298
                     'exception' => $exception
299 299
                 ]);
300 300
                 if ($throwErrors) {
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             }
305 305
             $this->logger->info(sprintf('Inserting/updating %s records into table %s...', $totalRecords, $tableName));
306 306
 
307
-            $select = $this->connection->prepare('SELECT * FROM ' . $tableName . ' WHERE id = :id');
307
+            $select = $this->connection->prepare('SELECT * FROM '.$tableName.' WHERE id = :id');
308 308
 
309 309
             $this->connection->beginTransaction();
310 310
 
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 
377 377
                     // If there is some columns updated in local_update, we skip them to avoid Zoho values to overide them
378 378
                     if ($localUpdateTableExists && $result['uid']) {
379
-                        $selectRecordInLocalUpdate = $this->connection->prepare('SELECT field_name FROM local_update WHERE table_name = "' . $tableName . '" AND uid = :uid');
379
+                        $selectRecordInLocalUpdate = $this->connection->prepare('SELECT field_name FROM local_update WHERE table_name = "'.$tableName.'" AND uid = :uid');
380 380
                         $selectRecordInLocalUpdate->execute(['uid' => $result['uid']]);
381 381
                         $resultsInLocalUpdate = $selectRecordInLocalUpdate->fetchAll(\PDO::FETCH_ASSOC);
382 382
                         $fieldsUpdated = [];
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
             }
408 408
 
409 409
             $this->logger->info(sprintf('Deleting %d records from table %s...', $totalRecordsDeleted, $tableName));
410
-            $sqlStatementUid = 'select uid from ' . $this->connection->quoteIdentifier($tableName) . ' where id = :id';
410
+            $sqlStatementUid = 'select uid from '.$this->connection->quoteIdentifier($tableName).' where id = :id';
411 411
             $processedRecords = 0;
412 412
             $logOffset = $totalRecordsDeleted >= 500 ? 100 : 50;
413 413
             foreach ($deletedRecords as $deletedRecord) {
@@ -439,10 +439,10 @@  discard block
 block discarded – undo
439 439
                 if ($zohoSyncConfigTableExists) {
440 440
                     $latestDateToSave = $currentDateTime->format('Y-m-d H:i:s');
441 441
                     if ($tableHasColumnModifiedTime) {
442
-                        $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM ' . $tableName);
442
+                        $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName);
443 443
                     }
444 444
                     if (!$latestDateToSave && $tableHasColumnCreatedTime) {
445
-                        $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM ' . $tableName);
445
+                        $latestDateToSave = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName);
446 446
                     }
447 447
                     if (!$latestDateToSave) {
448 448
                         $latestDateToSave = $currentDateTime->format('Y-m-d H:i:s');
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
         $table = $this->connection->getSchemaManager()->createSchema()->getTable($tableName);
467 467
         $apiModuleName = $dao->getPluralModuleName();
468 468
 
469
-        $this->logger->notice('Starting bulk fetch for module ' . $apiModuleName . '...');
469
+        $this->logger->notice('Starting bulk fetch for module '.$apiModuleName.'...');
470 470
 
471 471
         $zohoClient = new ZohoClient([
472 472
             'client_id' => ZOHO_CRM_CLIENT_ID,
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
             $oauthToken = $zohoClient->getZohoOAuthClient()->getAccessToken(ZOHO_CRM_CLIENT_CURRENT_USER_EMAIL);
486 486
 
487 487
             // Step 1: Create a bulk read job
488
-            $this->logger->info('Creating read job for module ' . $apiModuleName . ' and page ' . $page . '...');
489
-            $response = $client->request('POST', 'https://' . (ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www') . '.zohoapis.com/crm/bulk/v2/read', [
488
+            $this->logger->info('Creating read job for module '.$apiModuleName.' and page '.$page.'...');
489
+            $response = $client->request('POST', 'https://'.(ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www').'.zohoapis.com/crm/bulk/v2/read', [
490 490
                 'http_errors' => false,
491 491
                 'headers' => [
492
-                    'Authorization' => 'Zoho-oauthtoken ' . $oauthToken
492
+                    'Authorization' => 'Zoho-oauthtoken '.$oauthToken
493 493
                 ],
494 494
                 'json' => [
495 495
                     'query' => [
@@ -507,23 +507,23 @@  discard block
 block discarded – undo
507 507
 
508 508
                 // We don't care about the job status right now, it will be checked later
509 509
             } else {
510
-                $this->logger->error('Cannot create bulk read query for module ' . $apiModuleName . ': status: ' . $response->getStatusCode() . '. Status: ' . $response->getBody()->getContents());
510
+                $this->logger->error('Cannot create bulk read query for module '.$apiModuleName.': status: '.$response->getStatusCode().'. Status: '.$response->getBody()->getContents());
511 511
                 break;
512 512
             }
513 513
 
514 514
             if ($jobId === null) {
515
-                $this->logger->error('JobID cannot be null. json:' . $resultStr);
515
+                $this->logger->error('JobID cannot be null. json:'.$resultStr);
516 516
                 break;
517 517
             }
518 518
 
519 519
             // Step 2: Check job status
520 520
             $jobDetails = null;
521 521
             while (true) {
522
-                $this->logger->info('Checking job ' . $jobId . ' status for module ' . $apiModuleName . ' and page ' . $page . '...');
523
-                $response = $client->request('GET', 'https://' . (ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www') . '.zohoapis.com/crm/bulk/v2/read/' . $jobId, [
522
+                $this->logger->info('Checking job '.$jobId.' status for module '.$apiModuleName.' and page '.$page.'...');
523
+                $response = $client->request('GET', 'https://'.(ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www').'.zohoapis.com/crm/bulk/v2/read/'.$jobId, [
524 524
                     'http_errors' => false,
525 525
                     'headers' => [
526
-                        'Authorization' => 'Zoho-oauthtoken ' . $oauthToken
526
+                        'Authorization' => 'Zoho-oauthtoken '.$oauthToken
527 527
                     ]
528 528
                 ]);
529 529
                 if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
@@ -541,15 +541,15 @@  discard block
 block discarded – undo
541 541
                             $jobDetails = $json;
542 542
                             break;
543 543
                         } else {
544
-                            $this->logger->info('Unsupported job status: ' . $resultStr);
544
+                            $this->logger->info('Unsupported job status: '.$resultStr);
545 545
                             break;
546 546
                         }
547 547
                     } else {
548
-                        $this->logger->error('Unsupported response: ' . $resultStr);
548
+                        $this->logger->error('Unsupported response: '.$resultStr);
549 549
                         break;
550 550
                     }
551 551
                 } else {
552
-                    $this->logger->error('Cannot get bulk job status query for module ' . $apiModuleName . ': status: ' . $response->getStatusCode() . '. Status: ' . $response->getBody()->getContents());
552
+                    $this->logger->error('Cannot get bulk job status query for module '.$apiModuleName.': status: '.$response->getStatusCode().'. Status: '.$response->getBody()->getContents());
553 553
                     break;
554 554
                 }
555 555
                 sleep(15);
@@ -557,31 +557,31 @@  discard block
 block discarded – undo
557 557
 
558 558
             // Step 3: Download the result
559 559
             if ($jobDetails === null) {
560
-                $this->logger->error('JobDetails cannot be empty. json:' . $resultStr);
560
+                $this->logger->error('JobDetails cannot be empty. json:'.$resultStr);
561 561
                 break;
562 562
             }
563 563
             $this->logger->debug(json_encode($jobDetails));
564
-            $this->logger->info('Downloading zip file for module ' . $apiModuleName . ' and page ' . $page . '...');
565
-            $jobZipFile = '/tmp/job_' . $dao->getZCRMModule()->getAPIName() . '_' . $jobDetails['data'][0]['id'] . '.zip';
564
+            $this->logger->info('Downloading zip file for module '.$apiModuleName.' and page '.$page.'...');
565
+            $jobZipFile = '/tmp/job_'.$dao->getZCRMModule()->getAPIName().'_'.$jobDetails['data'][0]['id'].'.zip';
566 566
             $jobCsvPath = '/tmp/job_extract';
567
-            $jobCsvFile = '/tmp/job_extract/' . $jobDetails['data'][0]['id'] . '.csv';
567
+            $jobCsvFile = '/tmp/job_extract/'.$jobDetails['data'][0]['id'].'.csv';
568 568
             $canProcessCsv = false;
569 569
 
570
-            $response = $client->request('GET', 'https://' . (ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www') . '.zohoapis.com/crm/bulk/v2/read/' . $jobId . '/result', [
570
+            $response = $client->request('GET', 'https://'.(ZOHO_CRM_SANDBOX === 'true' ? 'sandbox' : 'www').'.zohoapis.com/crm/bulk/v2/read/'.$jobId.'/result', [
571 571
                 'http_errors' => false,
572 572
                 'headers' => [
573
-                    'Authorization' => 'Zoho-oauthtoken ' . $oauthToken
573
+                    'Authorization' => 'Zoho-oauthtoken '.$oauthToken
574 574
                 ],
575 575
                 'sink' => $jobZipFile
576 576
             ]);
577 577
             if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
578
-                $this->logger->info('Extracting ' . $jobZipFile . ' file for module ' . $apiModuleName . ' and page ' . $page . '...');
578
+                $this->logger->info('Extracting '.$jobZipFile.' file for module '.$apiModuleName.' and page '.$page.'...');
579 579
                 $zip = new ZipArchive();
580 580
                 $res = $zip->open($jobZipFile);
581 581
                 if ($res === TRUE) {
582 582
                     $zip->extractTo($jobCsvPath);
583 583
                     $zip->close();
584
-                    $this->logger->info('File extracted in ' . $jobCsvFile);
584
+                    $this->logger->info('File extracted in '.$jobCsvFile);
585 585
                     $canProcessCsv = true;
586 586
                 } else {
587 587
                     switch ($res) {
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
                             $zipErrorMessage = "Unknow (Code $res)";
614 614
                             break;
615 615
                     }
616
-                    $this->logger->error('Error when extracting zip file: ' . $zipErrorMessage);
616
+                    $this->logger->error('Error when extracting zip file: '.$zipErrorMessage);
617 617
                     break;
618 618
                 }
619 619
             } else {
620
-                $this->logger->error('Cannot download results for module ' . $apiModuleName . ': status: ' . $response->getStatusCode() . '. Status: ' . $response->getBody()->getContents());
620
+                $this->logger->error('Cannot download results for module '.$apiModuleName.': status: '.$response->getStatusCode().'. Status: '.$response->getBody()->getContents());
621 621
                 break;
622 622
             }
623 623
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
             $this->logger->info('Saving records to db...');
639 639
             $nbRecords = $jobDetails['data'][0]['result']['count'];
640 640
             $whenToLog = ceil($nbRecords / 100);
641
-            $this->logger->info($nbRecords . ' records to save');
641
+            $this->logger->info($nbRecords.' records to save');
642 642
             $nbSaved = 0;
643 643
             $handle = fopen($jobCsvFile, 'r');
644 644
             $fields = [];
@@ -656,30 +656,30 @@  discard block
 block discarded – undo
656 656
                             $recordDataToInsert[$decodedColumnName] = $value === '' ? null : $value;
657 657
                         } else {
658 658
                             if ($columnName === 'Owner' || $columnName === 'Created_By' || $columnName === 'Modified_By') {
659
-                                $recordDataToInsert[$decodedColumnName . '_OwnerID'] = $value === '' ? null : $value;
660
-                                $recordDataToInsert[$decodedColumnName . '_OwnerName'] = $users[$value] ?? null;
661
-                            } else if ($table->hasColumn($decodedColumnName . '_ID')) {
662
-                                $recordDataToInsert[$decodedColumnName . '_ID'] = $value === '' ? null : $value;
659
+                                $recordDataToInsert[$decodedColumnName.'_OwnerID'] = $value === '' ? null : $value;
660
+                                $recordDataToInsert[$decodedColumnName.'_OwnerName'] = $users[$value] ?? null;
661
+                            } else if ($table->hasColumn($decodedColumnName.'_ID')) {
662
+                                $recordDataToInsert[$decodedColumnName.'_ID'] = $value === '' ? null : $value;
663 663
                             }
664 664
                         }
665 665
                     }
666 666
                     $this->connection->insert($tableName, $recordDataToInsert);
667 667
                     ++$nbSaved;
668 668
                     if (($nbSaved % $whenToLog) === 0) {
669
-                        $this->logger->info($nbSaved . '/' . $nbRecords . ' records processed');
669
+                        $this->logger->info($nbSaved.'/'.$nbRecords.' records processed');
670 670
                     }
671 671
                 }
672
-                $this->logger->info($nbSaved . ' records saved for module ' . $apiModuleName . ' and page ' . $page);
672
+                $this->logger->info($nbSaved.' records saved for module '.$apiModuleName.' and page '.$page);
673 673
                 fclose($handle);
674 674
             }
675 675
 
676 676
             // Step 5: Check if there is more results
677 677
             $hasMoreRecords = $jobDetails['data'][0]['result']['more_records'];
678 678
             if (!$hasMoreRecords) {
679
-                $this->logger->info('No more records for the module ' . $apiModuleName);
679
+                $this->logger->info('No more records for the module '.$apiModuleName);
680 680
                 break;
681 681
             }
682
-            $this->logger->info('More records to fetch for the module ' . $apiModuleName);
682
+            $this->logger->info('More records to fetch for the module '.$apiModuleName);
683 683
             ++$page;
684 684
         }
685 685
     }
Please login to merge, or discard this patch.