| Conditions | 16 |
| Paths | 864 |
| Total Lines | 83 |
| Code Lines | 63 |
| 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 |
||
| 55 | protected function prepareView(): void |
||
| 56 | { |
||
| 57 | date_default_timezone_set($this->getSessionData('PBXTimezone')); |
||
| 58 | $roSession = $this->sessionRO; |
||
| 59 | $this->view->PBXVersion = $this->getSessionData('PBXVersion'); |
||
| 60 | if ($roSession !== null && array_key_exists('auth', $roSession)) { |
||
| 61 | $this->view->SSHPort = $this->getSessionData('SSHPort'); |
||
| 62 | $this->view->PBXLicense = $this->getSessionData('PBXLicense'); |
||
| 63 | } else { |
||
| 64 | $this->view->SSHPort = ''; |
||
| 65 | $this->view->PBXLicense = ''; |
||
| 66 | } |
||
| 67 | // Кеш версий модулей и атс, для правильной работы АТС при установке модулей |
||
| 68 | $versionHash = $this->getVersionsHash(); |
||
| 69 | $this->session->set('versionHash', $versionHash); |
||
| 70 | |||
| 71 | $this->view->WebAdminLanguage = $this->getSessionData('WebAdminLanguage'); |
||
| 72 | $this->view->AvailableLanguages = json_encode($this->elements->getAvailableWebAdminLanguages()); |
||
| 73 | |||
| 74 | if ($roSession !== null && array_key_exists('SubmitMode', $roSession)) { |
||
| 75 | $this->view->submitMode = $roSession['SubmitMode']; |
||
| 76 | } else { |
||
| 77 | $this->view->submitMode = 'SaveSettings'; |
||
| 78 | } |
||
| 79 | |||
| 80 | // Добавим версию модуля, если это модуль |
||
| 81 | if ($this->moduleName === 'PBXExtension') { |
||
| 82 | $module = PbxExtensionModules::findFirstByUniqid($this->controllerName); |
||
| 83 | if ($module === null) { |
||
| 84 | $module = new PbxExtensionModules(); |
||
| 85 | $module->disabled = '1'; |
||
|
|
|||
| 86 | $module->name = 'Unknown module'; |
||
| 87 | } |
||
| 88 | $this->view->module = $module; |
||
| 89 | } |
||
| 90 | |||
| 91 | // Разрешим отправку анонимной информации об ошибках |
||
| 92 | if ($this->getSessionData('SendMetrics') === '1') { |
||
| 93 | touch('/tmp/sendmetrics'); |
||
| 94 | $this->view->lastSentryEventId = SentrySdk::getCurrentHub()->getLastEventId(); |
||
| 95 | } else { |
||
| 96 | if (file_exists('/tmp/sendmetrics')) { |
||
| 97 | unlink('/tmp/sendmetrics'); |
||
| 98 | } |
||
| 99 | $this->view->lastSentryEventId = null; |
||
| 100 | } |
||
| 101 | $title = 'MikoPBX'; |
||
| 102 | switch ($this->actionName) { |
||
| 103 | case'index': |
||
| 104 | case'delete': |
||
| 105 | case'save': |
||
| 106 | case'modify': |
||
| 107 | case'*** WITHOUT ACTION ***': |
||
| 108 | $title .= '|'. $this->translation->_("Breadcrumb{$this->controllerName}"); |
||
| 109 | break; |
||
| 110 | default: |
||
| 111 | $title .= '|'. $this->translation->_("Breadcrumb{$this->controllerName}{$this->actionName}"); |
||
| 112 | } |
||
| 113 | Tag::setTitle($title); |
||
| 114 | $this->view->t = $this->translation; |
||
| 115 | $this->view->debugMode = $this->config->path('adminApplication.debugMode'); |
||
| 116 | $this->view->urlToLogo = $this->url->get('assets/img/logo-mikopbx.svg'); |
||
| 117 | if ($this->language === 'ru') { |
||
| 118 | $this->view->urlToWiki |
||
| 119 | = "https://wiki.mikopbx.com/{$this->controllerNameUnCamelized}"; |
||
| 120 | $this->view->urlToSupport |
||
| 121 | = 'https://www.mikopbx.ru/support/?fromPBX=true'; |
||
| 122 | } else { |
||
| 123 | $this->view->urlToWiki |
||
| 124 | = "https://wiki.mikopbx.com/{$this->language}:{$this->controllerNameUnCamelized}"; |
||
| 125 | $this->view->urlToSupport |
||
| 126 | = 'https://www.mikopbx.com/support/?fromPBX=true'; |
||
| 127 | } |
||
| 128 | |||
| 129 | $this->view->urlToController = $this->url->get($this->controllerNameUnCamelized); |
||
| 130 | $this->view->represent = ''; |
||
| 131 | $this->view->cacheName = "{$this->controllerName}{$this->actionName}{$this->language}{$versionHash}"; |
||
| 132 | |||
| 133 | // Подключим нужный View |
||
| 134 | if ($this->moduleName === 'PBXExtension') { |
||
| 135 | $this->view->setTemplateAfter('modules'); |
||
| 136 | } else { |
||
| 137 | $this->view->setTemplateAfter('main'); |
||
| 138 | } |
||
| 266 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..