Code Duplication    Length = 12-18 lines in 4 locations

src/Api/Regions.php 1 location

@@ 58-69 (lines=12) @@
55
56
        $this->response = $this->cacheValue($cache);
57
58
        if ($this->response == null) {
59
            $response = $this->_get(
60
                'v3.1/lookup/regions',
61
                $lang
62
            );
63
            if($this->config->getCache()){
64
                (!file_exists($this->cacheDir)) ?
65
                mkdir($this->cacheDir, 0777, false) : ((file_exists($cache)) ? unlink($cache) : touch($cache));
66
                file_put_contents($cache, serialize($response));
67
            }
68
            $this->response = $response;
69
        }
70
71
        return $this;
72
    }

src/Api/Cities.php 1 location

@@ 68-82 (lines=15) @@
65
66
        $this->response = $this->cacheValue($cache);
67
68
        if ($this->response == null) {
69
            $response = $this->_get(
70
                'v3.1/lookup/cities',
71
                $lang,
72
                [
73
                    'regionid' => $regionId
74
                ]
75
            );
76
            if ($this->config->getCache()) {
77
                (!file_exists($this->cacheDir)) ?
78
                mkdir($this->cacheDir, 0777, false) : ((file_exists($cache)) ? unlink($cache) : touch($cache));
79
                file_put_contents($cache, serialize($response));
80
            }
81
            $this->response = $response;
82
        }
83
84
        return $this;
85
    }

src/Api/Districts.php 1 location

@@ 59-73 (lines=15) @@
56
57
        $this->response = $this->cacheValue($cache);
58
59
        if ($this->response == null) {
60
            $response = $this->_get(
61
                'v3.1/lookup/districts',
62
                $lang,
63
                [
64
                    'cityid' => $cityId
65
                ]
66
            );
67
            if ($this->config->getCache()) {
68
                (!file_exists($this->cacheDir)) ?
69
                    mkdir($this->cacheDir, 0755, false) : ((file_exists($cache)) ? unlink($cache) : touch($cache));
70
                file_put_contents($cache, serialize($response));
71
            }
72
            $this->response = $response;
73
        }
74
75
        return $this;
76
    }

src/Api/Geo.php 1 location

@@ 60-77 (lines=18) @@
57
58
        $this->response = $this->cacheValue($cache);
59
60
        if ($this->response == null) {
61
            $response = $this->_get(
62
                'v3.1/Address/address-geocode',
63
                $lang,
64
                [
65
                    'lat'   => $latitude,
66
                    'long'  => $longitude
67
                ]
68
            );
69
70
            if($this->config->getCache()){
71
                (!file_exists($this->cacheDir)) ?
72
                mkdir($this->cacheDir, 0755, false):
73
                ((file_exists($cache)) ? unlink($cache):touch($cache));
74
                file_put_contents($cache, serialize($response));
75
            }
76
            $this->response = $response;
77
        }
78
79
        return $this;
80
    }