Completed
Branch master (954974)
by Steven
06:07 queued 44s
created

GeoPlugin::url()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Stevebauman\Location\Drivers;
4
5
use Illuminate\Support\Fluent;
6
use Stevebauman\Location\Position;
7
8
class GeoPlugin extends Driver
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    protected function url()
14
    {
15
        return 'http://www.geoplugin.net/php.gp?ip=';
16
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 View Code Duplication
    protected function hydrate(Position $position, Fluent $location)
0 ignored issues
show
Duplication introduced by Steve Bauman
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...
22
    {
23
        $position->countryCode = $location->geoplugin_countryCode;
24
        $position->countryName = $location->geoplugin_countryName;
25
        $position->regionName = $location->geoplugin_regionName;
26
        $position->regionCode = $location->geoplugin_regionCode;
27
        $position->cityName = $location->geoplugin_city;
28
        $position->latitude = $location->geoplugin_latitude;
29
        $position->longitude = $location->geoplugin_longitude;
30
        $position->areaCode = $location->geoplugin_areaCode;
31
32
        return $position;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 View Code Duplication
    protected function process($ip)
0 ignored issues
show
Duplication introduced by Steve Bauman
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...
39
    {
40
        try {
41
            $response = unserialize(file_get_contents($this->url().$ip));
42
43
            return new Fluent($response);
44
        } catch (\Exception $e) {
45
            return false;
46
        }
47
    }
48
}
49