Conditions | 29 |
Paths | 187 |
Total Lines | 106 |
Code Lines | 83 |
Lines | 0 |
Ratio | 0 % |
Changes | 10 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
91 | private function synchronizeDbModel(AbstractZohoDao $dao, $twoWaysSync) |
||
92 | { |
||
93 | $tableName = $this->getTableName($dao); |
||
94 | $this->logger->info("Synchronizing DB Model for ".$tableName); |
||
95 | |||
96 | $schema = new Schema(); |
||
97 | $table = $schema->createTable($tableName); |
||
98 | |||
99 | $flatFields = $this->getFlatFields($dao->getFields()); |
||
|
|||
100 | |||
101 | $table->addColumn('id', 'string', ['length' => 100]); |
||
102 | $table->setPrimaryKey(['id']); |
||
103 | |||
104 | foreach ($flatFields as $field) { |
||
105 | $columnName = $field['name']; |
||
106 | |||
107 | $length = null; |
||
108 | $index = false; |
||
109 | |||
110 | // Note: full list of types available here: https://www.zoho.com/crm/help/customization/custom-fields.html |
||
111 | switch ($field['type']) { |
||
112 | case 'Lookup ID': |
||
113 | case 'Lookup': |
||
114 | $type = 'string'; |
||
115 | $length = 100; |
||
116 | $index = true; |
||
117 | break; |
||
118 | case 'OwnerLookup': |
||
119 | $type = 'string'; |
||
120 | $index = true; |
||
121 | $length = 25; |
||
122 | break; |
||
123 | case 'Formula': |
||
124 | // Note: a Formula can return any type, but we have no way to know which type it returns... |
||
125 | $type = 'string'; |
||
126 | $length = 100; |
||
127 | break; |
||
128 | case 'DateTime': |
||
129 | $type = 'datetime'; |
||
130 | break; |
||
131 | case 'Date': |
||
132 | $type = 'date'; |
||
133 | break; |
||
134 | case 'DateTime': |
||
135 | $type = 'datetime'; |
||
136 | break; |
||
137 | case 'Boolean': |
||
138 | $type = 'boolean'; |
||
139 | break; |
||
140 | case 'TextArea': |
||
141 | $type = 'text'; |
||
142 | break; |
||
143 | case 'BigInt': |
||
144 | $type = 'bigint'; |
||
145 | break; |
||
146 | case 'Phone': |
||
147 | case 'Auto Number': |
||
148 | case 'Text': |
||
149 | case 'URL': |
||
150 | case 'Email': |
||
151 | case 'Website': |
||
152 | case 'Pick List': |
||
153 | case 'Multiselect Pick List': |
||
154 | $type = 'string'; |
||
155 | $length = $field['maxlength']; |
||
156 | break; |
||
157 | case 'Double': |
||
158 | case 'Percent': |
||
159 | $type = 'float'; |
||
160 | break; |
||
161 | case 'Integer': |
||
162 | $type = 'integer'; |
||
163 | break; |
||
164 | case 'Currency': |
||
165 | case 'Decimal': |
||
166 | $type = 'decimal'; |
||
167 | break; |
||
168 | default: |
||
169 | throw new \RuntimeException('Unknown type "'.$field['type'].'"'); |
||
170 | } |
||
171 | |||
172 | $options = []; |
||
173 | |||
174 | if ($length) { |
||
175 | $options['length'] = $length; |
||
176 | } |
||
177 | |||
178 | //$options['notnull'] = $field['req']; |
||
179 | $options['notnull'] = false; |
||
180 | |||
181 | $table->addColumn($columnName, $type, $options); |
||
182 | |||
183 | if ($index) { |
||
184 | $table->addIndex([$columnName]); |
||
185 | } |
||
186 | } |
||
187 | |||
188 | $dbalTableDiffService = new DbalTableDiffService($this->connection, $this->logger); |
||
189 | $hasChanges = $dbalTableDiffService->createOrUpdateTable($table); |
||
190 | |||
191 | if ($twoWaysSync && $hasChanges) { |
||
192 | $this->localChangesTracker->createInsertTrigger($table); |
||
193 | $this->localChangesTracker->createDeleteTrigger($table); |
||
194 | $this->localChangesTracker->createUpdateTrigger($table); |
||
195 | } |
||
196 | } |
||
197 | |||
323 |
This check looks for access to methods that are not accessible from the current context.
If you need to make a method accessible to another context you can raise its visibility level in the defining class.