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