@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->logger = $logger; |
48 | 48 | } |
49 | 49 | $this->apiLimitInsertUpdateDelete = $apiLimitInsertUpdateDelete; |
50 | - if($apiLimitInsertUpdateDelete === null) { |
|
50 | + if ($apiLimitInsertUpdateDelete === null) { |
|
51 | 51 | $this->apiLimitInsertUpdateDelete = 100; |
52 | 52 | } |
53 | 53 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $localTable = $update ? 'local_update' : 'local_insert'; |
83 | 83 | $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix); |
84 | - do{ |
|
84 | + do { |
|
85 | 85 | $rowsDeleted = []; |
86 | 86 | //@see https://www.zoho.com/crm/help/api/v2/#ra-update-records |
87 | 87 | //To optimize your API usage, get maximum 200 records with each request and insert, update or delete maximum 100 records with each request. |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | $rowsDeleted[] = $row['uid']; |
129 | 129 | } |
130 | 130 | } |
131 | - if($zohoBeans) { |
|
131 | + if ($zohoBeans) { |
|
132 | 132 | $this->sendDataToZohoCleanLocal($zohoDao, $zohoBeans, $rowsDeleted, $update); |
133 | 133 | } |
134 | 134 | $countToPush = $this->countElementInTable($zohoDao, $update); |
135 | - } while($countToPush > 0); |
|
135 | + } while ($countToPush > 0); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param string[] $rowsDeleted |
142 | 142 | * @param bool $update |
143 | 143 | */ |
144 | - private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans,$rowsDeleted, $update = false) |
|
144 | + private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans, $rowsDeleted, $update = false) |
|
145 | 145 | { |
146 | 146 | $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix); |
147 | 147 | $zohoDao->save($zohoBeans); |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | // ID not exist we can update the new row with the Zoho ID |
154 | 154 | $this->connection->beginTransaction(); |
155 | 155 | $this->connection->update($tableName, ['id' => $zohoBean->getZohoId()], ['uid' => $uid]); |
156 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
156 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
157 | 157 | $this->connection->commit(); |
158 | 158 | } else { |
159 | 159 | //ID already exist we need to delete the duplicate row. |
160 | 160 | $this->connection->beginTransaction(); |
161 | - $this->connection->delete($tableName, ['uid' => $uid ]); |
|
162 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
161 | + $this->connection->delete($tableName, ['uid' => $uid]); |
|
162 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
163 | 163 | $this->connection->commit(); |
164 | 164 | } |
165 | 165 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | foreach ($row as $columnName => $columnValue) { |
189 | 189 | $fieldMethod = $dao->getFieldFromFieldName($columnName); |
190 | - if(!in_array($columnName, EntitiesGeneratorService::$defaultDateFields) && $fieldMethod |
|
190 | + if (!in_array($columnName, EntitiesGeneratorService::$defaultDateFields) && $fieldMethod |
|
191 | 191 | && (!in_array($columnName, ['id', 'uid'])) && !is_null($columnValue) |
192 | 192 | ) { |
193 | 193 | $type = $fieldMethod->getType(); |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | { |
232 | 232 | switch ($type) { |
233 | 233 | case 'date': |
234 | - $value = \DateTime::createFromFormat('Y-m-d', $value)?:null; |
|
234 | + $value = \DateTime::createFromFormat('Y-m-d', $value) ?: null; |
|
235 | 235 | break; |
236 | 236 | case 'datetime': |
237 | - $value = \DateTime::createFromFormat('Y-m-d H:i:s', $value)?:null; |
|
237 | + $value = \DateTime::createFromFormat('Y-m-d H:i:s', $value) ?: null; |
|
238 | 238 | break; |
239 | 239 | case 'boolean' : |
240 | 240 | $value = (bool) $value; |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | $table = $schema->createTable($tableName); |
86 | 86 | |
87 | 87 | //@Temporary fix to use Mysql5.7 not strict |
88 | - $table->addColumn('uid', 'string', ['length' => 36,'notnull'=>false]); |
|
89 | - $table->addColumn('id', 'string', ['length' => 100,'notnull'=>false]); |
|
88 | + $table->addColumn('uid', 'string', ['length' => 36, 'notnull'=>false]); |
|
89 | + $table->addColumn('id', 'string', ['length' => 100, 'notnull'=>false]); |
|
90 | 90 | $table->addUniqueIndex(['id']); |
91 | 91 | $table->setPrimaryKey(['uid']); |
92 | 92 | |
93 | 93 | foreach ($dao->getFields() as $field) { |
94 | 94 | $columnName = $field->getName(); |
95 | 95 | //It seems sometime we can have the same field twice in the list of fields from the API. |
96 | - if($table->hasColumn($columnName)) { |
|
96 | + if ($table->hasColumn($columnName)) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | |
@@ -104,23 +104,23 @@ discard block |
||
104 | 104 | switch ($field->getType()) { |
105 | 105 | case 'fileupload': |
106 | 106 | $type = 'string'; |
107 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
107 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 255; |
|
108 | 108 | break; |
109 | 109 | case 'lookup': |
110 | 110 | $type = 'string'; |
111 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 100; |
|
111 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 100; |
|
112 | 112 | $index = true; |
113 | 113 | break; |
114 | 114 | case 'userlookup': |
115 | 115 | case 'ownerlookup': |
116 | 116 | $type = 'string'; |
117 | 117 | $index = true; |
118 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 25; |
|
118 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 25; |
|
119 | 119 | break; |
120 | 120 | case 'formula': |
121 | 121 | // Note: a Formula can return any type, but we have no way to know which type it returns... |
122 | 122 | $type = 'string'; |
123 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 100; |
|
123 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 100; |
|
124 | 124 | break; |
125 | 125 | case 'datetime': |
126 | 126 | $type = 'datetime'; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | case 'picklist': |
145 | 145 | case 'website': |
146 | 146 | $type = 'string'; |
147 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
147 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 255; |
|
148 | 148 | break; |
149 | 149 | case 'multiselectlookup': |
150 | 150 | case 'multiuserlookup': |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | case 'autonumber': |
161 | 161 | case 'integer': |
162 | 162 | $type = 'integer'; |
163 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
163 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 255; |
|
164 | 164 | break; |
165 | 165 | case 'currency': |
166 | 166 | case 'decimal': |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $schema = new Schema(); |
213 | 213 | $table = $schema->createTable($tableName); |
214 | 214 | |
215 | - $table->addColumn('id', 'string', ['length' => 100,'notnull'=>false]); |
|
215 | + $table->addColumn('id', 'string', ['length' => 100, 'notnull'=>false]); |
|
216 | 216 | $table->setPrimaryKey(['id']); |
217 | 217 | foreach (\ZCRMUser::$defaultKeys as $field) { |
218 | 218 | if ($field === 'id') { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $this->zohoDatabaseModelSync = $zohoDatabaseModelSync; |
101 | 101 | $this->zohoDatabaseCopier = $zohoDatabaseCopier; |
102 | 102 | $this->zohoDatabaseSync = $zohoDatabaseSync; |
103 | - $this->zohoEntitiesGenerator = $zohoEntitiesGenerator; |
|
103 | + $this->zohoEntitiesGenerator = $zohoEntitiesGenerator; |
|
104 | 104 | $this->zohoClient = $zohoClient; |
105 | 105 | $this->pathZohoDaos = $pathZohoDaos; |
106 | 106 | $this->namespaceZohoDaos = $namespaceZohoDaos; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $this->lock->acquireLock(); |
129 | 129 | } |
130 | 130 | |
131 | - if(!$input->getOption('limit')) { |
|
131 | + if (!$input->getOption('limit')) { |
|
132 | 132 | ini_set('memory_limit', '-1'); |
133 | 133 | } |
134 | 134 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | { |
259 | 259 | $output->writeln('Starting synchronize Zoho data into Zoho CRM.'); |
260 | 260 | foreach ($this->zohoDaos as $zohoDao) { |
261 | - if($zohoDao->getFieldFromFieldName('createdTime')) { |
|
261 | + if ($zohoDao->getFieldFromFieldName('createdTime')) { |
|
262 | 262 | $this->zohoDatabaseSync->pushToZoho($zohoDao); |
263 | 263 | } |
264 | 264 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $object = $user->{$fieldMethod}(); |
103 | 103 | $data[$column->getName()] = $object->getName(); |
104 | 104 | } |
105 | - elseif($column->getName() === 'Currency') { |
|
105 | + elseif ($column->getName() === 'Currency') { |
|
106 | 106 | //Todo: Do a pull request about \ZCRMUser::geCurrency() to \ZCRMUser::getCurrency() |
107 | 107 | $data[$column->getName()] = $user->geCurrency(); |
108 | 108 | } |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | $select->execute(['id' => $user->getId()]); |
115 | 115 | $result = $select->fetch(\PDO::FETCH_ASSOC); |
116 | 116 | if ($result === false && $data) { |
117 | - $this->logger->debug("Inserting record with ID '" . $user->getId() . "'."); |
|
117 | + $this->logger->debug("Inserting record with ID '".$user->getId()."'."); |
|
118 | 118 | |
119 | 119 | $data['id'] = $user->getId(); |
120 | 120 | $types['id'] = 'string'; |
121 | 121 | |
122 | 122 | $this->connection->insert($tableName, $data, $types); |
123 | - } elseif($data) { |
|
124 | - $this->logger->debug("Updating record with ID '" . $user->getId() . "'."); |
|
123 | + } elseif ($data) { |
|
124 | + $this->logger->debug("Updating record with ID '".$user->getId()."'."); |
|
125 | 125 | $identifier = ['id' => $user->getId()]; |
126 | 126 | $types['id'] = 'string'; |
127 | 127 | $this->connection->update($tableName, $data, $identifier, $types); |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | // Let's get the last modification date: |
150 | 150 | $tableDetail = $this->connection->getSchemaManager()->listTableDetails($tableName); |
151 | 151 | $lastActivityTime = null; |
152 | - if($tableDetail->hasColumn('modifiedTime')) { |
|
152 | + if ($tableDetail->hasColumn('modifiedTime')) { |
|
153 | 153 | $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName); |
154 | 154 | } |
155 | - if(!$lastActivityTime && $tableDetail->hasColumn('createdTime')) { |
|
155 | + if (!$lastActivityTime && $tableDetail->hasColumn('createdTime')) { |
|
156 | 156 | $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName); |
157 | 157 | } |
158 | 158 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | continue; |
190 | 190 | } else { |
191 | 191 | $field = $dao->getFieldFromFieldName($column->getName()); |
192 | - if(!$field) { |
|
192 | + if (!$field) { |
|
193 | 193 | continue; |
194 | 194 | } |
195 | 195 | $getterName = $field->getGetter(); |