Conditions | 13 |
Paths | 112 |
Total Lines | 32 |
Code Lines | 23 |
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 |
||
15 | public function init() { |
||
16 | if (!empty(App::$primary->config['site']['domain'])) { |
||
17 | $domain = App::$primary->config['site']['domain']; |
||
18 | } else { |
||
19 | $domain = implode('.', array_slice(explode('.', idn_to_utf8(INJI_DOMAIN_NAME)), -2)); |
||
20 | } |
||
21 | $alias = str_replace($domain, '', idn_to_utf8(INJI_DOMAIN_NAME)); |
||
22 | $city = null; |
||
23 | if ($alias) { |
||
24 | $alias = str_replace('.', '', $alias); |
||
25 | $city = Geography\City::get($alias, 'alias'); |
||
26 | } |
||
27 | if (!$city) { |
||
28 | if (!file_exists(App::$primary->path . $this->geographyDbDir . '/SxGeoCity.dat')) { |
||
29 | $this->updateDb(); |
||
30 | } |
||
31 | if (file_exists(App::$primary->path . $this->geographyDbDir . '/SxGeoCity.dat')) { |
||
32 | $SxGeo = new Geography\SxGeo(App::$primary->path . $this->geographyDbDir . '/SxGeoCity.dat'); |
||
33 | $cityIp = $SxGeo->getCity($_SERVER['REMOTE_ADDR']); |
||
34 | if (!empty($cityIp['city']['name_ru'])) { |
||
35 | $city = Geography\City::get($cityIp['city']['name_ru'], 'name'); |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 | if (!$city) { |
||
40 | $city = Geography\City::get(1, 'default'); |
||
41 | } |
||
42 | if (!empty($this->config['aliasRedirect']) && $city && $city->alias && !$alias && Module::$cur->moduleName !== 'Exchange1c') { |
||
43 | Tools::redirect('//' . $city->alias . '.' . $domain . $_SERVER['REQUEST_URI']); |
||
44 | } |
||
45 | Geography\City::$cur = $city; |
||
|
|||
46 | } |
||
47 | |||
117 |
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..