Conditions | 44 |
Paths | > 20000 |
Total Lines | 156 |
Code Lines | 129 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
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 |
||
183 | private function fillModifiedTables($data): void |
||
184 | { |
||
185 | $count_changes = count($this->modified_tables); |
||
186 | $called_class = $data['model'] ?? ''; |
||
187 | |||
188 | // Обновление настроек в объектах, в оперативной памяти. |
||
189 | $additionalModules = $this->di->getShared('pbxConfModules'); |
||
190 | foreach ($additionalModules as $appClass) { |
||
191 | // Проверим, зависит ли объект от измененных данных. |
||
192 | $dependences = $appClass->dependenceModels(); |
||
193 | if (in_array($called_class, $dependences)){ |
||
194 | // Получаем новые настройки. |
||
195 | $appClass->getSettings(); |
||
196 | } |
||
197 | } |
||
198 | |||
199 | switch ($called_class) { |
||
200 | case AsteriskManagerUsers::class: |
||
201 | $this->modified_tables[self::R_MANAGERS] = true; |
||
202 | break; |
||
203 | case CallQueueMembers::class: |
||
204 | $this->modified_tables[self::R_QUEUES] = true; |
||
205 | break; |
||
206 | case CallQueues::class: |
||
207 | $this->modified_tables[self::R_QUEUES] = true; |
||
208 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
209 | break; |
||
210 | case ConferenceRooms::class: |
||
211 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
212 | break; |
||
213 | case CustomFiles::class: |
||
214 | $this->modified_tables[self::R_CUSTOM_F] = true; |
||
215 | break; |
||
216 | case DialplanApplications::class: |
||
217 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
218 | break; |
||
219 | case ExtensionForwardingRights::class: |
||
220 | $this->modified_tables[self::R_SIP] = true; |
||
221 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
222 | break; |
||
223 | case Extensions::class: |
||
224 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
225 | break; |
||
226 | case ExternalPhones::class: |
||
227 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
228 | break; |
||
229 | case Fail2BanRules::class: |
||
230 | $this->modified_tables[self::R_FIREWALL] = true; |
||
231 | break; |
||
232 | case FirewallRules::class: |
||
233 | $this->modified_tables[self::R_FIREWALL] = true; |
||
234 | break; |
||
235 | case Iax::class: |
||
236 | $this->modified_tables[self::R_IAX] = true; |
||
237 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
238 | break; |
||
239 | case Codecs::class: |
||
240 | $this->modified_tables[self::R_IAX] = true; |
||
241 | $this->modified_tables[self::R_SIP] = true; |
||
242 | break; |
||
243 | case IncomingRoutingTable::class: |
||
244 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
245 | break; |
||
246 | case IvrMenu::class: |
||
247 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
248 | break; |
||
249 | case SoundFiles::class: |
||
250 | $this->modified_tables[self::R_MOH] = true; |
||
251 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
252 | break; |
||
253 | case IvrMenuActions::class: |
||
254 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
255 | break; |
||
256 | case LanInterfaces::class: |
||
257 | $this->modified_tables[self::R_NETWORK] = true; |
||
258 | $this->modified_tables[self::R_IAX] = true; |
||
259 | $this->modified_tables[self::R_SIP] = true; |
||
260 | break; |
||
261 | case NetworkFilters::class: |
||
262 | $this->modified_tables[self::R_FIREWALL] = true; |
||
263 | $this->modified_tables[self::R_SIP] = true; |
||
264 | $this->modified_tables[self::R_MANAGERS] = true; |
||
265 | break; |
||
266 | case OutgoingRoutingTable::class: |
||
267 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
268 | break; |
||
269 | case OutWorkTimes::class: |
||
270 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
271 | break; |
||
272 | case PbxSettings::class: |
||
273 | $this->modified_tables[self::R_PBX_SETTINGS] = true; |
||
274 | $this->pbxSettings->key = $data['recordId'] ?? ''; |
||
275 | if ($this->pbxSettings->itHasFeaturesSettingsChanges()) { |
||
276 | $this->modified_tables[self::R_FEATURES] = true; |
||
277 | } |
||
278 | if ($this->pbxSettings->itHasAMIParametersChanges()) { |
||
279 | $this->modified_tables[self::R_MANAGERS] = true; |
||
280 | } |
||
281 | if ($this->pbxSettings->itHasIaxParametersChanges()) { |
||
282 | $this->modified_tables[self::R_IAX] = true; |
||
283 | } |
||
284 | if ($this->pbxSettings->itHasSipParametersChanges()) { |
||
285 | $this->modified_tables[self::R_SIP] = true; |
||
286 | } |
||
287 | if ($this->pbxSettings->itHasSSHParametersChanges()) { |
||
288 | $this->modified_tables[self::R_SSH] = true; |
||
289 | } |
||
290 | if ($this->pbxSettings->itHasFirewallParametersChanges()) { |
||
291 | $this->modified_tables[self::R_FIREWALL] = true; |
||
292 | } |
||
293 | if ($this->pbxSettings->itHasWebParametersChanges()) { |
||
294 | $this->modified_tables[self::R_NGINX] = true; |
||
295 | } |
||
296 | if ($this->pbxSettings->itHasCronParametersChanges()) { |
||
297 | $this->modified_tables[self::R_CRON] = true; |
||
298 | } |
||
299 | if ($this->pbxSettings->itHasDialplanParametersChanges()) { |
||
300 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
301 | } |
||
302 | if ($this->pbxSettings->itHasVoiceMailParametersChanges()) { |
||
303 | $this->modified_tables[self::R_VOICEMAIL] = true; |
||
304 | } |
||
305 | if ($this->pbxSettings->itHasVisualLanguageSettings()) { |
||
306 | $this->modified_tables[self::R_REST_API_WORKER] = true; |
||
307 | } |
||
308 | if ($this->pbxSettings->itHasLicenseSettings()) { |
||
309 | $this->modified_tables[self::R_LICENSE] = true; |
||
310 | $this->modified_tables[self::R_NATS] = true; |
||
311 | } |
||
312 | if ($this->pbxSettings->itHasTimeZoneSettings()) { |
||
313 | $this->modified_tables[self::R_TIMEZONE] = true; |
||
314 | $this->modified_tables[self::R_NGINX] = true; |
||
315 | $this->modified_tables[self::R_PHP_FPM] = true; |
||
316 | $this->modified_tables[self::R_REST_API_WORKER] = true; |
||
317 | } |
||
318 | if ($this->pbxSettings->itHasNTPSettings()) { |
||
319 | $this->modified_tables[self::R_NTP] = true; |
||
320 | } |
||
321 | if ($this->pbxSettings->itHasCallRecordSettings()) { |
||
322 | $this->modified_tables[ self::R_CALL_EVENTS_WORKER] = true; |
||
323 | } |
||
324 | break; |
||
325 | case Sip::class: |
||
326 | $this->modified_tables[self::R_SIP] = true; |
||
327 | $this->modified_tables[self::R_DIALPLAN] = true; |
||
328 | break; |
||
329 | case PbxExtensionModules::class: |
||
330 | $this->modified_tables[self::R_CONF_MODULES] = true; |
||
331 | $this->modified_tables[self::R_CRON] = true; |
||
332 | break; |
||
333 | default: |
||
334 | } |
||
335 | |||
336 | if ($count_changes === 0 && count($this->modified_tables) > 0) { |
||
337 | // Начинаем отсчет времени при получении первой задачи. |
||
338 | $this->last_change = time(); |
||
339 | } |
||
580 | } |