| Conditions | 1 |
| Paths | 1 |
| Total Lines | 259 |
| Code Lines | 172 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 215 | public function initialize(): void |
||
| 216 | { |
||
| 217 | $this->setSource('m_Extensions'); |
||
| 218 | parent::initialize(); |
||
| 219 | $this->belongsTo( |
||
| 220 | 'userid', |
||
| 221 | Users::class, |
||
| 222 | 'id', |
||
| 223 | [ |
||
| 224 | 'alias' => 'Users', |
||
| 225 | 'foreignKey' => [ |
||
| 226 | 'allowNulls' => true, |
||
| 227 | 'action' => Relation::NO_ACTION, |
||
| 228 | ], |
||
| 229 | ] |
||
| 230 | ); |
||
| 231 | $this->hasOne( |
||
| 232 | 'number', |
||
| 233 | Sip::class, |
||
| 234 | 'extension', |
||
| 235 | [ |
||
| 236 | 'alias' => 'Sip', |
||
| 237 | 'foreignKey' => [ |
||
| 238 | 'allowNulls' => false, |
||
| 239 | 'action' => Relation::ACTION_CASCADE, |
||
| 240 | ], |
||
| 241 | ] |
||
| 242 | ); |
||
| 243 | $this->hasOne( |
||
| 244 | 'number', |
||
| 245 | ExternalPhones::class, |
||
| 246 | 'extension', |
||
| 247 | [ |
||
| 248 | 'alias' => 'ExternalPhones', |
||
| 249 | 'foreignKey' => [ |
||
| 250 | 'allowNulls' => false, |
||
| 251 | 'action' => Relation::ACTION_CASCADE, |
||
| 252 | ], |
||
| 253 | ] |
||
| 254 | ); |
||
| 255 | $this->hasOne( |
||
| 256 | 'number', |
||
| 257 | DialplanApplications::class, |
||
| 258 | 'extension', |
||
| 259 | [ |
||
| 260 | 'alias' => 'DialplanApplications', |
||
| 261 | 'foreignKey' => [ |
||
| 262 | 'allowNulls' => false, |
||
| 263 | 'action' => Relation::ACTION_CASCADE // DialplanApplications is always deleted through its Extension |
||
| 264 | ], |
||
| 265 | ] |
||
| 266 | ); |
||
| 267 | $this->hasOne( |
||
| 268 | 'number', |
||
| 269 | ConferenceRooms::class, |
||
| 270 | 'extension', |
||
| 271 | [ |
||
| 272 | 'alias' => 'ConferenceRooms', |
||
| 273 | 'foreignKey' => [ |
||
| 274 | 'allowNulls' => false, |
||
| 275 | 'action' => Relation::ACTION_CASCADE // ConferenceRooms is always deleted through its Extension |
||
| 276 | ], |
||
| 277 | ] |
||
| 278 | ); |
||
| 279 | |||
| 280 | $this->hasOne( |
||
| 281 | 'number', |
||
| 282 | CallQueues::class, |
||
| 283 | 'extension', |
||
| 284 | [ |
||
| 285 | 'alias' => 'CallQueues', |
||
| 286 | 'foreignKey' => [ |
||
| 287 | 'allowNulls' => false, |
||
| 288 | 'action' => Relation::ACTION_CASCADE // CallQueues is always deleted through its Extension |
||
| 289 | ], |
||
| 290 | ] |
||
| 291 | ); |
||
| 292 | $this->hasMany( |
||
| 293 | 'number', |
||
| 294 | CallQueues::class, |
||
| 295 | 'timeout_extension', |
||
| 296 | [ |
||
| 297 | 'alias' => 'CallQueueRedirectRightsTimeout', |
||
| 298 | 'foreignKey' => [ |
||
| 299 | 'allowNulls' => true, |
||
| 300 | 'message' => 'CallQueueRedirectRightsTimeout', |
||
| 301 | 'action' => Relation::ACTION_RESTRICT, |
||
| 302 | ], |
||
| 303 | ] |
||
| 304 | ); |
||
| 305 | $this->hasMany( |
||
| 306 | 'number', |
||
| 307 | CallQueues::class, |
||
| 308 | 'redirect_to_extension_if_empty', |
||
| 309 | [ |
||
| 310 | 'alias' => 'CallQueueRedirectRightsIfEmpty', |
||
| 311 | 'foreignKey' => [ |
||
| 312 | 'allowNulls' => true, |
||
| 313 | 'message' => 'CallQueueRedirectRightsIfEmpty', |
||
| 314 | 'action' => Relation::ACTION_RESTRICT, |
||
| 315 | ], |
||
| 316 | ] |
||
| 317 | ); |
||
| 318 | $this->hasMany( |
||
| 319 | 'number', |
||
| 320 | CallQueues::class, |
||
| 321 | 'redirect_to_extension_if_unanswered', |
||
| 322 | [ |
||
| 323 | 'alias' => 'CallQueueRedirectRightsIfUnanswered', |
||
| 324 | 'foreignKey' => [ |
||
| 325 | 'allowNulls' => true, |
||
| 326 | 'message' => 'CallQueueRedirectRightsIfUnanswered', |
||
| 327 | 'action' => Relation::ACTION_RESTRICT, |
||
| 328 | ], |
||
| 329 | ] |
||
| 330 | ); |
||
| 331 | $this->hasMany( |
||
| 332 | 'number', |
||
| 333 | CallQueues::class, |
||
| 334 | 'redirect_to_extension_if_repeat_exceeded', |
||
| 335 | [ |
||
| 336 | 'alias' => 'CallQueueRedirectRightsIfRepeatExceeded', |
||
| 337 | 'foreignKey' => [ |
||
| 338 | 'allowNulls' => true, |
||
| 339 | 'message' => 'CallQueueRedirectRightsIfRepeatExceeded', |
||
| 340 | 'action' => Relation::ACTION_RESTRICT, |
||
| 341 | ], |
||
| 342 | ] |
||
| 343 | ); |
||
| 344 | |||
| 345 | $this->hasMany( |
||
| 346 | 'number', |
||
| 347 | CallQueueMembers::class, |
||
| 348 | 'extension', |
||
| 349 | [ |
||
| 350 | 'alias' => 'CallQueueMembers', |
||
| 351 | 'foreignKey' => [ |
||
| 352 | 'allowNulls' => false, |
||
| 353 | 'action' => Relation::ACTION_CASCADE, // CallQueueMembers is always deleted through its Extension |
||
| 354 | ], |
||
| 355 | ] |
||
| 356 | ); |
||
| 357 | $this->hasMany( |
||
| 358 | 'number', |
||
| 359 | IncomingRoutingTable::class, |
||
| 360 | 'extension', |
||
| 361 | [ |
||
| 362 | 'alias' => 'IncomingRoutingTable', |
||
| 363 | 'foreignKey' => [ |
||
| 364 | 'allowNulls' => false, |
||
| 365 | 'action' => Relation::ACTION_RESTRICT, |
||
| 366 | ], |
||
| 367 | 'params' => [ |
||
| 368 | 'order' => 'priority asc', |
||
| 369 | ], |
||
| 370 | ] |
||
| 371 | ); |
||
| 372 | $this->hasMany( |
||
| 373 | 'number', |
||
| 374 | OutWorkTimes::class, |
||
| 375 | 'extension', |
||
| 376 | [ |
||
| 377 | 'alias' => 'OutWorkTimes', |
||
| 378 | 'foreignKey' => [ |
||
| 379 | 'allowNulls' => false, |
||
| 380 | 'action' => Relation::ACTION_RESTRICT, |
||
| 381 | ], |
||
| 382 | ] |
||
| 383 | ); |
||
| 384 | $this->hasOne( |
||
| 385 | 'number', |
||
| 386 | ExtensionForwardingRights::class, |
||
| 387 | 'extension', |
||
| 388 | [ |
||
| 389 | 'alias' => 'ExtensionForwardingRights', |
||
| 390 | 'foreignKey' => [ |
||
| 391 | 'allowNulls' => false, |
||
| 392 | 'action' => Relation::ACTION_CASCADE, // ExtensionForwardingRights is always deleted through its Extension |
||
| 393 | ], |
||
| 394 | ] |
||
| 395 | ); |
||
| 396 | |||
| 397 | $this->hasMany( |
||
| 398 | 'number', |
||
| 399 | ExtensionForwardingRights::class, |
||
| 400 | 'forwarding', |
||
| 401 | [ |
||
| 402 | 'alias' => 'ExtensionForwardingRightsForwarding', |
||
| 403 | 'foreignKey' => [ |
||
| 404 | 'allowNulls' => false, |
||
| 405 | 'message' => 'ExtensionForwardingRightsForwarding', |
||
| 406 | 'action' => Relation::ACTION_RESTRICT, |
||
| 407 | ], |
||
| 408 | ] |
||
| 409 | ); |
||
| 410 | $this->hasMany( |
||
| 411 | 'number', |
||
| 412 | ExtensionForwardingRights::class, |
||
| 413 | 'forwardingonbusy', |
||
| 414 | [ |
||
| 415 | 'alias' => 'ExtensionForwardingRightsForwardingOnBusy', |
||
| 416 | 'foreignKey' => [ |
||
| 417 | 'allowNulls' => false, |
||
| 418 | 'message' => 'ExtensionForwardingRightsForwardingOnBusy', |
||
| 419 | 'action' => Relation::ACTION_RESTRICT, |
||
| 420 | ], |
||
| 421 | ] |
||
| 422 | ); |
||
| 423 | $this->hasMany( |
||
| 424 | 'number', |
||
| 425 | ExtensionForwardingRights::class, |
||
| 426 | 'forwardingonunavailable', |
||
| 427 | [ |
||
| 428 | 'alias' => 'ExtensionForwardingRightsOnUnavailable', |
||
| 429 | 'foreignKey' => [ |
||
| 430 | 'allowNulls' => false, |
||
| 431 | 'message' => 'ExtensionForwardingRightsOnUnavailable', |
||
| 432 | 'action' => Relation::ACTION_RESTRICT, |
||
| 433 | ], |
||
| 434 | ] |
||
| 435 | ); |
||
| 436 | |||
| 437 | $this->hasOne( |
||
| 438 | 'number', |
||
| 439 | IvrMenu::class, |
||
| 440 | 'extension', |
||
| 441 | [ |
||
| 442 | 'alias' => 'IvrMenu', |
||
| 443 | 'foreignKey' => [ |
||
| 444 | 'allowNulls' => false, |
||
| 445 | 'action' => Relation::ACTION_CASCADE // IvrMenu is always deleted through its Extension |
||
| 446 | ], |
||
| 447 | ] |
||
| 448 | ); |
||
| 449 | |||
| 450 | $this->hasMany( |
||
| 451 | 'number', |
||
| 452 | IvrMenu::class, |
||
| 453 | 'timeout_extension', |
||
| 454 | [ |
||
| 455 | 'alias' => 'IvrMenuTimeout', |
||
| 456 | 'foreignKey' => [ |
||
| 457 | 'message' => 'IvrMenuTimeout', |
||
| 458 | 'allowNulls' => false, |
||
| 459 | 'action' => Relation::ACTION_RESTRICT |
||
| 460 | // Restrict the deletion of an internal number if it is used in an IVR menu timeout |
||
| 461 | ], |
||
| 462 | ] |
||
| 463 | ); |
||
| 464 | |||
| 465 | $this->hasMany( |
||
| 466 | 'number', |
||
| 467 | IvrMenuActions::class, |
||
| 468 | 'extension', |
||
| 469 | [ |
||
| 470 | 'alias' => 'IvrMenuActions', |
||
| 471 | 'foreignKey' => [ |
||
| 472 | 'allowNulls' => false, |
||
| 473 | 'action' => Relation::ACTION_RESTRICT |
||
| 474 | // Restrict the deletion of an internal number if it is used in an IVR menu actions |
||
| 607 | } |