Completed
Push — master ( edab47...f40fd3 )
by Steven
01:00
created

Position::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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