Completed
Pull Request — 2.0 (#27)
by Raphaël
01:36
created
src/ZohoDatabasePusher.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             $this->logger = $logger;
47 47
         }
48 48
         $this->apiLimitInsertUpdateDelete = $apiLimitInsertUpdateDelete;
49
-        if($apiLimitInsertUpdateDelete === null){
49
+        if ($apiLimitInsertUpdateDelete === null) {
50 50
             $this->apiLimitInsertUpdateDelete = 100;
51 51
         }
52 52
     }
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
         //To optimize your API usage, get maximum 200 records with each request and insert, update or delete maximum 100 records with each request.
131 131
         $offsetTodo = 0;
132 132
         $doneBeans = 0;
133
-        while($doneBeans < $countItems){
134
-            $zohoBeansToSend = array_slice($zohoBeans,$offsetTodo,$this->apiLimitInsertUpdateDelete,true);
133
+        while ($doneBeans < $countItems) {
134
+            $zohoBeansToSend = array_slice($zohoBeans, $offsetTodo, $this->apiLimitInsertUpdateDelete, true);
135 135
             $finalRowsDeleted = array_keys($zohoBeansToSend);
136
-            $this->sendDataToZohoCleanLocal($zohoDao,$zohoBeans,$finalRowsDeleted,$update);
136
+            $this->sendDataToZohoCleanLocal($zohoDao, $zohoBeans, $finalRowsDeleted, $update);
137 137
             $offsetTodo += $this->apiLimitInsertUpdateDelete;
138 138
             $doneBeans += count($zohoBeansToSend);
139 139
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      * @param string[] $rowsDeleted
146 146
      * @param bool $update
147 147
      */
148
-    private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans,$rowsDeleted, $update = false)
148
+    private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans, $rowsDeleted, $update = false)
149 149
     {
150 150
         $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix);
151 151
         $zohoDao->save($zohoBeans);
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
                     // ID not exist we can update the new row with the Zoho ID
158 158
                     $this->connection->beginTransaction();
159 159
                     $this->connection->update($tableName, ['id' => $zohoBean->getZohoId()], ['uid' => $uid]);
160
-                    $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]);
160
+                    $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]);
161 161
                     $this->connection->commit();
162 162
                 } else {
163 163
                     //ID already exist we need to delete the duplicate row.
164 164
                     $this->connection->beginTransaction();
165
-                    $this->connection->delete($tableName, ['uid' => $uid ]);
166
-                    $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]);
165
+                    $this->connection->delete($tableName, ['uid' => $uid]);
166
+                    $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]);
167 167
                     $this->connection->commit();
168 168
                 }
169 169
             }
Please login to merge, or discard this patch.