Conditions | 15 |
Paths | 224 |
Total Lines | 35 |
Code Lines | 25 |
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 (!empty($_COOKIE['curcity'])) { |
||
40 | $city = \Geography\City::get((int) $_COOKIE['curcity']); |
||
41 | } |
||
42 | if (!$city) { |
||
43 | $city = Geography\City::get(1, 'default'); |
||
44 | } |
||
45 | if (!empty($this->config['aliasRedirect']) && $city && $city->alias && !$city->default && !$alias && Module::$cur->moduleName !== 'Exchange1c') { |
||
46 | Tools::redirect('//' . $city->alias . '.' . $domain . $_SERVER['REQUEST_URI']); |
||
|
|||
47 | } |
||
48 | Geography\City::$cur = $city; |
||
49 | } |
||
50 | |||
120 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths