Passed
Push — develop ( 822734...2a560f )
by Nikolay
04:48
created
src/Common/Models/ModelsBase.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             $moduleDir = PbxExtensionUtils::getModuleDir($module['uniqid']);
71 71
 
72 72
             $moduleJson = "{$moduleDir}/module.json";
73
-            if ( ! file_exists($moduleJson)) {
73
+            if (!file_exists($moduleJson)) {
74 74
                 continue;
75 75
             }
76 76
             $jsonString            = file_get_contents($moduleJson);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             }
82 82
 
83 83
             $moduleModelsDir = "{$moduleDir}/Models";
84
-            $results         = glob($moduleModelsDir . '/*.php', GLOB_NOSORT);
84
+            $results         = glob($moduleModelsDir.'/*.php', GLOB_NOSORT);
85 85
             foreach ($results as $file) {
86 86
                 $className        = pathinfo($file)['filename'];
87 87
                 $moduleModelClass = "\\Modules\\{$module['uniqid']}\\Models\\{$className}";
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
                 $newErrorMessage = $this->t('ConstraintViolation');
117 117
                 $newErrorMessage .= "<ul class='list'>";
118 118
                 if ($relatedRecords === false) {
119
-                    throw new Model\Exception('Error on models relationship ' . $errorMessage);
119
+                    throw new Model\Exception('Error on models relationship '.$errorMessage);
120 120
                 }
121 121
                 if ($relatedRecords instanceof Resultset) {
122 122
                     foreach ($relatedRecords as $item) {
123 123
                         if ($item instanceof ModelsBase) {
124
-                            $newErrorMessage .= '<li>' . $item->getRepresent(true) . '</li>';
124
+                            $newErrorMessage .= '<li>'.$item->getRepresent(true).'</li>';
125 125
                         }
126 126
                     }
127 127
                 } elseif ($relatedRecords instanceof ModelsBase) {
128
-                    $newErrorMessage .= '<li>' . $relatedRecords->getRepresent(true) . '</li>';
128
+                    $newErrorMessage .= '<li>'.$relatedRecords->getRepresent(true).'</li>';
129 129
                 } else {
130 130
                     $newErrorMessage .= '<li>Unknown object</li>';
131 131
                 }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                 if (empty($this->id)) {
177 177
                     $name .= $this->t('mo_NewElementCallQueues');
178 178
                 } else {
179
-                    $name .= $this->t('mo_CallQueueShort4Dropdown') . ': ' . $this->name;
179
+                    $name .= $this->t('mo_CallQueueShort4Dropdown').': '.$this->name;
180 180
                 }
181 181
                 break;
182 182
             case ConferenceRooms::class:
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 if (empty($this->id)) {
185 185
                     $name .= $this->t('mo_NewElementConferenceRooms');
186 186
                 } else {
187
-                    $name .= $this->t('mo_ConferenceRoomsShort4Dropdown') . ': ' . $this->name;
187
+                    $name .= $this->t('mo_ConferenceRoomsShort4Dropdown').': '.$this->name;
188 188
                 }
189 189
                 break;
190 190
             case CustomFiles::class:
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 if (empty($this->id)) {
196 196
                     $name .= $this->t('mo_NewElementDialplanApplications');
197 197
                 } else {
198
-                    $name .= $this->t('mo_ApplicationShort4Dropdown') . ': ' . $this->name;
198
+                    $name .= $this->t('mo_ApplicationShort4Dropdown').': '.$this->name;
199 199
                 }
200 200
                 break;
201 201
             case ExtensionForwardingRights::class:
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                 if (empty($this->id)) {
258 258
                     $name .= $this->t('mo_NewElementIax');
259 259
                 } elseif ($this->disabled === '1') {
260
-                    $name .= "{$this->description} ({$this->t( 'mo_Disabled' )})";
260
+                    $name .= "{$this->description} ({$this->t('mo_Disabled')})";
261 261
                 } else {
262 262
                     $name .= $this->description;
263 263
                 }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                 if (empty($this->id)) {
268 268
                     $name .= $this->t('mo_NewElementIvrMenu');
269 269
                 } else {
270
-                    $name .= $this->t('mo_IVRMenuShort4Dropdown') . ': ' . $this->name;
270
+                    $name .= $this->t('mo_IVRMenuShort4Dropdown').': '.$this->name;
271 271
                 }
272 272
                 break;
273 273
             case IvrMenuActions::class:
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                 $name = '<i class="map signs icon"></i> ';
281 281
                 if (empty($this->id)) {
282 282
                     $name .= $this->t('mo_NewElementIncomingRoutingTable');
283
-                } elseif ( ! empty($this->note)) {
283
+                } elseif (!empty($this->note)) {
284 284
                     $name .= $this->t('repIncomingRoutingTable', ['represent' => $this->note]);
285 285
                 } else {
286 286
                     $name .= $this->t('repIncomingRoutingTableNumber', ['represent' => $this->id]);
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
                 if (empty($this->id)) {
296 296
                     $name .= $this->t('mo_NewElementNetworkFilters');
297 297
                 } else {
298
-                    $name .= $this->description . '('
299
-                        . $this->t('fw_PermitNetwork') . ': ' . $this->permit
298
+                    $name .= $this->description.'('
299
+                        . $this->t('fw_PermitNetwork').': '.$this->permit
300 300
                         . ')';
301 301
                 }
302 302
                 break;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
                 $name = '<i class="random icon"></i> ';
305 305
                 if (empty($this->id)) {
306 306
                     $name .= $this->t('mo_NewElementOutgoingRoutingTable');
307
-                } elseif ( ! empty($this->rulename)) {
307
+                } elseif (!empty($this->rulename)) {
308 308
                     $name .= $this->t('repOutgoingRoutingTable', ['represent' => $this->rulename]);
309 309
                 } else {
310 310
                     $name .= $this->t('repOutgoingRoutingTableNumber', ['represent' => $this->id]);
@@ -314,24 +314,24 @@  discard block
 block discarded – undo
314 314
                 $name = '<i class="time icon"></i> ';
315 315
                 if (empty($this->id)) {
316 316
                     $name .= $this->t('mo_NewElementOutWorkTimes');
317
-                } elseif ( ! empty($this->description)) {
317
+                } elseif (!empty($this->description)) {
318 318
                     $name .= $this->t('repOutWorkTimes', ['represent' => $this->description]);
319 319
                 } else {
320 320
                     $represent = '';
321 321
                     if (is_numeric($this->date_from)) {
322
-                        $represent .= date("d/m/Y", $this->date_from) . '-';
322
+                        $represent .= date("d/m/Y", $this->date_from).'-';
323 323
                     }
324 324
                     if (is_numeric($this->date_to)) {
325
-                        $represent .= date("d/m/Y", $this->date_to) . ' ';
325
+                        $represent .= date("d/m/Y", $this->date_to).' ';
326 326
                     }
327 327
                     if (isset($this->weekday_from)) {
328
-                        $represent .= $this->t(date('D', strtotime("Sunday +{$this->weekday_from} days"))) . '-';
328
+                        $represent .= $this->t(date('D', strtotime("Sunday +{$this->weekday_from} days"))).'-';
329 329
                     }
330 330
                     if (isset($this->weekday_to)) {
331
-                        $represent .= $this->t(date('D', strtotime("Sunday +{$this->weekday_to} days"))) . ' ';
331
+                        $represent .= $this->t(date('D', strtotime("Sunday +{$this->weekday_to} days"))).' ';
332 332
                     }
333 333
                     if (isset($this->time_from) || isset($this->time_to)) {
334
-                        $represent .= $this->time_from . ' - ' . $this->time_to . ' ';
334
+                        $represent .= $this->time_from.' - '.$this->time_to.' ';
335 335
                     }
336 336
                     $name .= $this->t('repOutWorkTimes', ['represent' => $represent]);
337 337
                 }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 break;
349 349
             case PbxExtensionModules::class:
350 350
                 $name = '<i class="puzzle piece icon"></i> '
351
-                    . $this->t('mo_ModuleShort4Dropdown') . ': '
351
+                    . $this->t('mo_ModuleShort4Dropdown').': '
352 352
                     . $this->name;
353 353
                 break;
354 354
             case Sip::class:
@@ -356,14 +356,14 @@  discard block
 block discarded – undo
356 356
                 if (empty($this->id)) {
357 357
                     $name .= $this->t('mo_NewElementSip');
358 358
                 } elseif ($this->disabled === '1') {
359
-                    $name .= "{$this->description} ({$this->t( 'mo_Disabled' )})";
359
+                    $name .= "{$this->description} ({$this->t('mo_Disabled')})";
360 360
                 } else {
361 361
                     $name .= $this->description;
362 362
                 }
363 363
 
364 364
                 break;
365 365
             case Users::class:
366
-                $name = '<i class="user outline icon"></i> ' . $this->username;
366
+                $name = '<i class="user outline icon"></i> '.$this->username;
367 367
                 break;
368 368
             case SoundFiles::class:
369 369
                 $name = '<i class="file audio outline icon"></i> ';
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
             $link     = $this->getWebInterfaceLink();
383 383
             $category = explode('\\', static::class)[3];
384 384
             $result   = $this->t(
385
-                'rep' . $category,
385
+                'rep'.$category,
386 386
                 [
387 387
                     'represent' => "<a href='{$link}'>{$name}</a>",
388 388
                 ]
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 
408 408
         if (strlen($s) > $max_length) {
409 409
             $offset = ($max_length - 3) - strlen($s);
410
-            $s      = substr($s, 0, strrpos($s, ' ', $offset)) . '...';
410
+            $s      = substr($s, 0, strrpos($s, ' ', $offset)).'...';
411 411
         }
412 412
 
413 413
         return $s;
@@ -426,80 +426,80 @@  discard block
 block discarded – undo
426 426
         $link    = '#';
427 427
         switch (static::class) {
428 428
             case AsteriskManagerUsers::class:
429
-                $link = $url->get('asterisk-managers/modify/' . $this->id, null, null, $baseUri);
429
+                $link = $url->get('asterisk-managers/modify/'.$this->id, null, null, $baseUri);
430 430
                 break;
431 431
             case CallQueueMembers::class:
432
-                $link = $url->get('call-queues/modify/' . $this->CallQueues->uniqid, null, null, $baseUri);
432
+                $link = $url->get('call-queues/modify/'.$this->CallQueues->uniqid, null, null, $baseUri);
433 433
                 break;
434 434
             case CallQueues::class:
435
-                $link = $url->get('call-queues/modify/' . $this->uniqid, null, null, $baseUri);
435
+                $link = $url->get('call-queues/modify/'.$this->uniqid, null, null, $baseUri);
436 436
                 break;
437 437
             case ConferenceRooms::class:
438
-                $link = $url->get('conference-rooms/modify/' . $this->uniqid, null, null, $baseUri);
438
+                $link = $url->get('conference-rooms/modify/'.$this->uniqid, null, null, $baseUri);
439 439
                 break;
440 440
             case CustomFiles::class:
441
-                $link = $url->get('custom-files/modify/' . $this->id, null, null, $baseUri);
441
+                $link = $url->get('custom-files/modify/'.$this->id, null, null, $baseUri);
442 442
                 break;
443 443
             case DialplanApplications::class:
444
-                $link = $url->get('dialplan-applications/modify/' . $this->uniqid, null, null, $baseUri);
444
+                $link = $url->get('dialplan-applications/modify/'.$this->uniqid, null, null, $baseUri);
445 445
                 break;
446 446
             case ExtensionForwardingRights::class:
447 447
 
448 448
                 break;
449 449
             case Extensions::class:
450
-                $link = $url->get('extensions/modify/' . $this->id, null, null, $baseUri);
450
+                $link = $url->get('extensions/modify/'.$this->id, null, null, $baseUri);
451 451
                 break;
452 452
             case ExternalPhones::class:
453 453
                 if ($this->Extensions->is_general_user_number === "1") {
454
-                    $parameters    = [
455
-                        'conditions' => 'is_general_user_number="1" AND type="' . Extensions::TYPE_EXTERNAL . '" AND userid=:userid:',
454
+                    $parameters = [
455
+                        'conditions' => 'is_general_user_number="1" AND type="'.Extensions::TYPE_EXTERNAL.'" AND userid=:userid:',
456 456
                         'bind'       => [
457 457
                             'userid' => $this->Extensions->userid,
458 458
                         ],
459 459
                     ];
460 460
                     $needExtension = Extensions::findFirst($parameters);
461
-                    $link          = $url->get('extensions/modify/' . $needExtension->id, null, null, $baseUri);
461
+                    $link          = $url->get('extensions/modify/'.$needExtension->id, null, null, $baseUri);
462 462
                 } else {
463
-                    $link = '#';//TODO сделать если будет раздел для допоплнинельных номеров пользователя
463
+                    $link = '#'; //TODO сделать если будет раздел для допоплнинельных номеров пользователя
464 464
                 }
465 465
                 break;
466 466
             case Fail2BanRules::class:
467
-                $link = '#';//TODO сделать если будет fail2ban
467
+                $link = '#'; //TODO сделать если будет fail2ban
468 468
                 break;
469 469
             case FirewallRules::class:
470
-                $link = $url->get('firewall/modify/' . $this->NetworkFilters->id, null, null, $baseUri);
470
+                $link = $url->get('firewall/modify/'.$this->NetworkFilters->id, null, null, $baseUri);
471 471
                 break;
472 472
             case Iax::class:
473
-                $link = $url->get('providers/modifyiax/' . $this->Providers->id, null, null, $baseUri);
473
+                $link = $url->get('providers/modifyiax/'.$this->Providers->id, null, null, $baseUri);
474 474
                 break;
475 475
             case IvrMenu::class:
476
-                $link = $url->get('ivr-menu/modify/' . $this->uniqid, null, null, $baseUri);
476
+                $link = $url->get('ivr-menu/modify/'.$this->uniqid, null, null, $baseUri);
477 477
                 break;
478 478
             case IvrMenuActions::class:
479
-                $link = $url->get('ivr-menu/modify/' . $this->IvrMenu->uniqid, null, null, $baseUri);
479
+                $link = $url->get('ivr-menu/modify/'.$this->IvrMenu->uniqid, null, null, $baseUri);
480 480
                 break;
481 481
             case Codecs::class:
482 482
                 break;
483 483
             case IncomingRoutingTable::class:
484
-                $link = $url->get('incoming-routes/modify/' . $this->id, null, null, $baseUri);
484
+                $link = $url->get('incoming-routes/modify/'.$this->id, null, null, $baseUri);
485 485
                 break;
486 486
             case LanInterfaces::class:
487 487
                 $link = $url->get('network/index/', null, null, $baseUri);
488 488
                 break;
489 489
             case NetworkFilters::class:
490
-                $link = $url->get('firewall/modify/' . $this->id, null, null, $baseUri);
490
+                $link = $url->get('firewall/modify/'.$this->id, null, null, $baseUri);
491 491
                 break;
492 492
             case OutgoingRoutingTable::class:
493
-                $link = $url->get('outbound-routes/modify/' . $this->id, null, null, $baseUri);
493
+                $link = $url->get('outbound-routes/modify/'.$this->id, null, null, $baseUri);
494 494
                 break;
495 495
             case OutWorkTimes::class:
496
-                $link = $url->get('out-off-work-time/modify/' . $this->id, null, null, $baseUri);
496
+                $link = $url->get('out-off-work-time/modify/'.$this->id, null, null, $baseUri);
497 497
                 break;
498 498
             case Providers::class:
499 499
                 if ($this->type === "IAX") {
500
-                    $link = $url->get('providers/modifyiax/' . $this->uniqid, null, null, $baseUri);
500
+                    $link = $url->get('providers/modifyiax/'.$this->uniqid, null, null, $baseUri);
501 501
                 } else {
502
-                    $link = $url->get('providers/modifysip/' . $this->uniqid, null, null, $baseUri);
502
+                    $link = $url->get('providers/modifysip/'.$this->uniqid, null, null, $baseUri);
503 503
                 }
504 504
                 break;
505 505
             case PbxSettings::class:
@@ -511,26 +511,26 @@  discard block
 block discarded – undo
511 511
             case Sip::class:
512 512
                 if ($this->Extensions) { // Это внутренний номер?
513 513
                     if ($this->Extensions->is_general_user_number === "1") {
514
-                        $link = $url->get('extensions/modify/' . $this->Extensions->id, null, null, $baseUri);
514
+                        $link = $url->get('extensions/modify/'.$this->Extensions->id, null, null, $baseUri);
515 515
                     } else {
516
-                        $link = '#';//TODO сделать если будет раздел для допоплнинельных номеров пользователя
516
+                        $link = '#'; //TODO сделать если будет раздел для допоплнинельных номеров пользователя
517 517
                     }
518 518
                 } elseif ($this->Providers) { // Это провайдер
519
-                    $link = $url->get('providers/modifysip/' . $this->Providers->id, null, null, $baseUri);
519
+                    $link = $url->get('providers/modifysip/'.$this->Providers->id, null, null, $baseUri);
520 520
                 }
521 521
                 break;
522 522
             case Users::class:
523
-                $parameters    = [
523
+                $parameters = [
524 524
                     'conditions' => 'userid=:userid:',
525 525
                     'bind'       => [
526 526
                         'userid' => $this->id,
527 527
                     ],
528 528
                 ];
529 529
                 $needExtension = Extensions::findFirst($parameters);
530
-                $link          = $url->get('extensions/modify/' . $needExtension->id, null, null, $baseUri);
530
+                $link          = $url->get('extensions/modify/'.$needExtension->id, null, null, $baseUri);
531 531
                 break;
532 532
             case SoundFiles::class:
533
-                $link = $url->get('sound-files/modify/' . $this->id, null, null, $baseUri);
533
+                $link = $url->get('sound-files/modify/'.$this->id, null, null, $baseUri);
534 534
                 break;
535 535
             default:
536 536
         }
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
         $metaData      = $this->di->get('modelsMetadata');
547 547
         $defaultValues = $metaData->getDefaultValues($this);
548 548
         foreach ($defaultValues as $field => $value) {
549
-            if ( ! isset($this->{$field})) {
549
+            if (!isset($this->{$field})) {
550 550
                 $this->{$field} = $value;
551 551
             }
552 552
         }
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
                 = $currentDeleteRecord->_modelsManager->getRelations(get_class($currentDeleteRecord));
681 681
         foreach ($relations as $relation) {
682 682
             $foreignKey = $relation->getOption('foreignKey');
683
-            if ( ! array_key_exists('action', $foreignKey)) {
683
+            if (!array_key_exists('action', $foreignKey)) {
684 684
                 continue;
685 685
             }
686 686
             // Check if there are some record which restrict delete current record
@@ -698,10 +698,10 @@  discard block
 block discarded – undo
698 698
                     ? ' OR ' : '';
699 699
                 $parameters['conditions']             .= $referencedField
700 700
                     . '= :field'
701
-                    . $index . ':';
701
+                    . $index.':';
702 702
                 $bindField
703 703
                                                       = $mappedFields[$index];
704
-                $parameters['bind']['field' . $index] = $currentDeleteRecord->$bindField;
704
+                $parameters['bind']['field'.$index] = $currentDeleteRecord->$bindField;
705 705
             }
706 706
             $relatedRecords = $relatedModel::find($parameters);
707 707
             switch ($foreignKey['action']) {
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
         if (php_sapi_name() === 'cli') {
776 776
             return;
777 777
         }
778
-        if ( ! $this->hasSnapshotData()) {
778
+        if (!$this->hasSnapshotData()) {
779 779
             return;
780 780
         } // nothing changed
781 781
 
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
     {
798 798
         // Add changed fields set to Beanstalkd queue
799 799
         $queue = $this->di->getShared('beanstalkConnectionModels');
800
-        if ($queue===null){
800
+        if ($queue === null) {
801 801
             return;
802 802
         }
803 803
         if ($this instanceof PbxSettings) {
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             && $di->getShared('registry')->booting !== true
857 857
         ) {
858 858
             $queue = $di->getShared('beanstalkConnectionCache');
859
-            if ($queue!==null) {
859
+            if ($queue !== null) {
860 860
                 $queue->publish(
861 861
                     $calledClass,
862 862
                     CacheCleanerPlugin::class,
Please login to merge, or discard this patch.