Mygento_Geoip_Model_Detect   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 76.47 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 13
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCityByIp() 13 13 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 *
5
 *
6
 * @category Mygento
7
 * @package Mygento_Geoip
8
 * @copyright 2014 NKS LLC. (https://www.mygento.ru)
9
 */
10
class Mygento_Geoip_Model_Detect extends Mygento_Geoip_Model_Abstract
11
{
12
13 View Code Duplication
    public function getCityByIp($ip)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
    {
15
        if (!$this->isFileExists()) {
16
            return null;
17
        }
18
        $SxGeo = new GeoIP_SxGeo($this->local_file);
19
        $city_full = $SxGeo->getCity($ip);
20
        unset($SxGeo);
21
        if ($city_full['city']['name_ru'] != '') {
22
            return $city_full['city']['name_ru'];
23
        }
24
        return null;
25
    }
26
}
27