| Conditions | 10 |
| Paths | 72 |
| Total Lines | 58 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 66 | protected function prepareView(): void |
||
| 67 | { |
||
| 68 | date_default_timezone_set(PbxSettings::getValueByKey('PBXTimezone')); |
||
| 69 | $this->view->PBXVersion = PbxSettings::getValueByKey('PBXVersion'); |
||
| 70 | $this->view->MetaTegHeadDescription = $this->translation->_('MetategHeadDescription'); |
||
| 71 | $this->view->isExternalModuleController = $this->isExternalModuleController; |
||
| 72 | if ($this->session->has(SessionController::SESSION_ID)) { |
||
| 73 | $this->view->PBXLicense = PbxSettings::getValueByKey('PBXLicense'); |
||
| 74 | } else { |
||
| 75 | $this->view->PBXLicense = ''; |
||
| 76 | } |
||
| 77 | $this->view->urlToWiki = "https://wiki.mikopbx.com/{$this->controllerNameUnCamelized}"; |
||
| 78 | if ($this->language === 'ru') { |
||
| 79 | $this->view->urlToSupport = 'https://www.mikopbx.ru/support/?fromPBX=true'; |
||
| 80 | } else { |
||
| 81 | $this->view->urlToSupport = 'https://www.mikopbx.com/support/?fromPBX=true'; |
||
| 82 | } |
||
| 83 | |||
| 84 | $this->view->WebAdminLanguage = PbxSettings::getValueByKey('WebAdminLanguage'); |
||
| 85 | $this->view->AvailableLanguages = json_encode($this->elements->getAvailableWebAdminLanguages()); |
||
| 86 | $this->view->submitMode = $this->session->get('SubmitMode') ?? 'SaveSettings'; |
||
| 87 | $this->view->lastSentryEventId = $this->setLastSentryEventId(); |
||
| 88 | |||
| 89 | $title = 'MikoPBX'; |
||
| 90 | switch ($this->actionName) { |
||
| 91 | case'index': |
||
| 92 | case'delete': |
||
| 93 | case'save': |
||
| 94 | case'modify': |
||
| 95 | case'*** WITHOUT ACTION ***': |
||
| 96 | $title .= '|' . $this->translation->_("Breadcrumb{$this->controllerName}"); |
||
| 97 | break; |
||
| 98 | default: |
||
| 99 | $title .= '|' . $this->translation->_("Breadcrumb{$this->controllerName}{$this->actionName}"); |
||
| 100 | } |
||
| 101 | Tag::setTitle($title); |
||
| 102 | $this->view->t = $this->translation; |
||
| 103 | $this->view->debugMode = $this->config->path('adminApplication.debugMode'); |
||
| 104 | $this->view->urlToLogo = $this->url->get('assets/img/logo-mikopbx.svg'); |
||
| 105 | $this->view->urlToController = $this->url->get($this->controllerNameUnCamelized); |
||
| 106 | $this->view->represent = ''; |
||
| 107 | |||
| 108 | // Add module variables into view |
||
| 109 | if ($this->isExternalModuleController) { |
||
| 110 | /** @var PbxExtensionModules $module */ |
||
| 111 | $module = PbxExtensionModules::findFirstByUniqid($this->controllerName); |
||
| 112 | if ($module === null) { |
||
| 113 | $module = new PbxExtensionModules(); |
||
| 114 | $module->disabled = '1'; |
||
| 115 | $module->name = 'Unknown module'; |
||
| 116 | } |
||
| 117 | $this->view->setVar('module', $module); |
||
| 118 | // If it is module we have to use another volt template |
||
| 119 | $this->view->setVar('globalModuleUniqueId', $module->uniqid); |
||
| 120 | $this->view->setTemplateAfter('modules'); |
||
| 121 | } else { |
||
| 122 | $this->view->setVar('globalModuleUniqueId', ''); |
||
| 123 | $this->view->setTemplateAfter('main'); |
||
| 124 | } |
||
| 250 |