Conditions | 10 |
Paths | 64 |
Total Lines | 45 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 18 | ||
Bugs | 6 | 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 |
||
84 | public function __construct() |
||
85 | { |
||
86 | // make alias for view pathway |
||
87 | $this->currentViewPath = App::$View->themePath; |
||
88 | |||
89 | // make alias for baseUrl, script url and domain |
||
90 | $this->baseDomain = App::$Request->getHttpHost(); |
||
91 | if (Str::likeEmpty($this->baseDomain)) { |
||
92 | $this->baseDomain = App::$Properties->get('baseDomain'); |
||
93 | } |
||
94 | // build script url |
||
95 | $this->scriptUrl = App::$Request->getScheme() . '://' . $this->baseDomain; |
||
96 | if (App::$Properties->get('basePath') !== '/') { |
||
97 | $this->scriptUrl .= rtrim(App::$Properties->get('basePath'), '/'); |
||
98 | } |
||
99 | // build base url (with current used interface path slug) |
||
100 | $this->baseUrl = $this->scriptUrl; |
||
101 | if (App::$Request->getInterfaceSlug() !== null) { |
||
102 | $this->baseUrl .= App::$Request->getInterfaceSlug(); |
||
103 | } |
||
104 | |||
105 | $this->baseUrlNoLang = $this->baseUrl; |
||
106 | if (App::$Request->languageInPath() && App::$Request->getLanguage() !== null) { |
||
107 | $this->baseUrl .= '/' . App::$Request->getLanguage(); |
||
108 | } |
||
109 | |||
110 | // add cron initiation from user if enabled |
||
111 | if ((bool)App::$Properties->get('userCron') && env_name === 'Front') { |
||
112 | $this->addPlainCode('js', 'if(Math.random() > 0.8) { $.get("' . $this->scriptUrl . '/cron.php?rand=" + Math.random()); }'); |
||
113 | } |
||
114 | |||
115 | // build vendor libs alias |
||
116 | $this->vendorNamedLibrary['js']['jquery'] = $this->scriptUrl . '/vendor/bower/jquery/dist/jquery.min.js'; |
||
117 | $this->vendorNamedLibrary['css']['bootstrap'] = $this->scriptUrl . '/vendor/bower/bootstrap/dist/css/bootstrap.min.css'; |
||
118 | $this->vendorNamedLibrary['js']['bootstrap'] = $this->scriptUrl . '/vendor/bower/bootstrap/dist/js/bootstrap.min.js'; |
||
119 | $this->vendorNamedLibrary['css']['fa'] = $this->scriptUrl . '/vendor/bower/components-font-awesome/css/font-awesome.min.css'; |
||
120 | $this->vendorNamedLibrary['js']['jquery-ui'] = $this->scriptUrl . '/vendor/bower/jquery-ui/jquery-ui.min.js'; |
||
121 | $this->vendorNamedLibrary['css']['jquery-ui'] = $this->scriptUrl . '/vendor/bower/jquery-ui/themes/base/jquery-ui.min.css'; |
||
122 | |||
123 | $themeAll = App::$Properties->get('theme'); |
||
124 | if (!isset($themeAll[env_name]) || Str::length($themeAll[env_name]) < 1) { |
||
125 | $themeAll[env_name] = 'default'; |
||
126 | } |
||
127 | $this->currentViewUrl = $this->scriptUrl . '/Apps/View/' . env_name . '/' . $themeAll[env_name]; |
||
128 | } |
||
129 | |||
197 | } |