Position   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 2
eloc 20
c 5
b 0
f 0
dl 0
loc 123
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
A isEmpty() 0 8 1
1
<?php
2
3
namespace Stevebauman\Location;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
7
class Position implements Arrayable
8
{
9
    /**
10
     * The IP address used to retrieve the location.
11
     *
12
     * @var string
13
     */
14
    public $ip;
15
16
    /**
17
     * The country name.
18
     *
19
     * @var string|null
20
     */
21
    public $countryName;
22
23
    /**
24
     * The country code.
25
     *
26
     * @var string|null
27
     */
28
    public $countryCode;
29
30
    /**
31
     * The region code.
32
     *
33
     * @var string|null
34
     */
35
    public $regionCode;
36
37
    /**
38
     * The region name.
39
     *
40
     * @var string|null
41
     */
42
    public $regionName;
43
44
    /**
45
     * The city name.
46
     *
47
     * @var string|null
48
     */
49
    public $cityName;
50
51
    /**
52
     * The zip code.
53
     *
54
     * @var string|null
55
     */
56
    public $zipCode;
57
58
    /**
59
     * The iso code.
60
     *
61
     * @var string|null
62
     */
63
    public $isoCode;
64
65
    /**
66
     * The postal code.
67
     *
68
     * @var string|null
69
     */
70
    public $postalCode;
71
72
    /**
73
     * The latitude.
74
     *
75
     * @var string|null
76
     */
77
    public $latitude;
78
79
    /**
80
     * The longitude.
81
     *
82
     * @var string|null
83
     */
84
    public $longitude;
85
86
    /**
87
     * The metro code.
88
     *
89
     * @var string|null
90
     */
91
    public $metroCode;
92
93
    /**
94
     * The area code.
95
     *
96
     * @var string|null
97
     */
98
    public $areaCode;
99
100
    /**
101
     * The driver used for retrieving the location.
102
     *
103
     * @var string|null
104
     */
105
    public $driver;
106
107
    /**
108
     * Determine if the position is empty.
109
     *
110
     * @return bool
111
     */
112
    public function isEmpty()
113
    {
114
        $data = $this->toArray();
115
116
        unset($data['ip']);
117
        unset($data['driver']);
118
119
        return empty(array_filter($data));
120
    }
121
122
    /**
123
     * Get the instance as an array.
124
     *
125
     * @return array
126
     */
127
    public function toArray()
128
    {
129
        return get_object_vars($this);
130
    }
131
}
132