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