Location   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 182
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 15
eloc 36
c 1
b 0
f 0
dl 0
loc 182
ccs 39
cts 39
cp 1
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A setHorizontalAccuracy() 0 6 2
A getLatitude() 0 3 1
A setLongitude() 0 6 2
A getHorizontalAccuracy() 0 3 1
A getLongitude() 0 3 1
A getLivePeriod() 0 3 1
A setLatitude() 0 6 2
A setProximityAlertRadius() 0 3 1
A getHeading() 0 3 1
A setHeading() 0 3 1
A setLivePeriod() 0 3 1
A getProximityAlertRadius() 0 3 1
1
<?php
2
3
namespace TelegramBot\Api\Types;
4
5
use TelegramBot\Api\BaseType;
6
use TelegramBot\Api\InvalidArgumentException;
7
use TelegramBot\Api\TypeInterface;
8
9
/**
10
 * Class Location
11
 * This object represents a point on the map.
12
 *
13
 * @package TelegramBot\Api\Types
14
 */
15
class Location extends BaseType implements TypeInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     *
20
     * @var array
21
     */
22
    protected static $requiredParams = ['latitude', 'longitude'];
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @var array
28
     */
29
    protected static $map = [
30
        'latitude' => true,
31
        'longitude' => true,
32
        'horizontal_accuracy' => true,
33
        'live_period' => true,
34
        'heading' => true,
35
        'proximity_alert_radius' => true,
36
    ];
37
38
    /**
39
     * Longitude as defined by sender
40
     *
41
     * @var float
42
     */
43
    protected $longitude;
44
45
    /**
46
     * Latitude as defined by sender
47
     *
48
     * @var float
49
     */
50
    protected $latitude;
51
52
    /**
53
     * Optional. The radius of uncertainty for the location, measured in meters; 0-1500
54
     *
55
     * @var float|null
56
     */
57
    protected $horizontalAccuracy;
58
59
    /**
60
     * Optional. Time relative to the message sending date, during which the location can be updated, in seconds. For
61
     * active live locations only.
62
     *
63
     * @var int|null
64
     */
65
    protected $livePeriod;
66
67
    /**
68
     * Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only.
69
     *
70
     * @var int|null
71
     */
72
    protected $heading;
73
74
    /**
75
     * Optional. Maximum distance for proximity alerts about approaching another chat member, in meters. For sent live
76
     * locations only.
77
     *
78
     * @var int|null
79
     */
80
    protected $proximityAlertRadius;
81
82
    /**
83
     * @return float
84
     */
85 1
    public function getLatitude()
86
    {
87 1
        return $this->latitude;
88
    }
89
90
    /**
91
     * @param mixed $latitude
92
     * @return void
93
     * @throws InvalidArgumentException
94
     */
95 8
    public function setLatitude($latitude)
96
    {
97 8
        if (is_float($latitude)) {
98 7
            $this->latitude = $latitude;
99 7
        } else {
100 1
            throw new InvalidArgumentException();
101
        }
102 7
    }
103
104
    /**
105
     * @return float
106
     */
107 1
    public function getLongitude()
108
    {
109 1
        return $this->longitude;
110
    }
111
112
    /**
113
     * @param mixed $longitude
114
     * @return void
115
     * @throws InvalidArgumentException
116
     */
117 8
    public function setLongitude($longitude)
118
    {
119 8
        if (is_float($longitude)) {
120 7
            $this->longitude = $longitude;
121 7
        } else {
122 1
            throw new InvalidArgumentException();
123
        }
124 7
    }
125
126
    /**
127
     * @return float|null
128
     */
129 1
    public function getHorizontalAccuracy()
130
    {
131 1
        return $this->horizontalAccuracy;
132
    }
133
134
    /**
135
     * @param mixed $horizontalAccuracy
136
     * @return void
137
     * @throws InvalidArgumentException
138
     */
139 4
    public function setHorizontalAccuracy($horizontalAccuracy)
140
    {
141 4
        if (is_float($horizontalAccuracy)) {
142 3
            $this->horizontalAccuracy = $horizontalAccuracy;
143 3
        } else {
144 1
            throw new InvalidArgumentException();
145
        }
146 3
    }
147
148
    /**
149
     * @return int|null
150
     */
151 1
    public function getLivePeriod()
152
    {
153 1
        return $this->livePeriod;
154
    }
155
156
    /**
157
     * @param int $livePeriod
158
     * @return void
159 3
     */
160
    public function setLivePeriod($livePeriod)
161 3
    {
162 3
        $this->livePeriod = $livePeriod;
163
    }
164
165
    /**
166
     * @return int|null
167 1
     */
168
    public function getHeading()
169 1
    {
170
        return $this->heading;
171
    }
172
173
    /**
174
     * @param int $heading
175 3
     * @return void
176
     */
177 3
    public function setHeading($heading)
178 3
    {
179
        $this->heading = $heading;
180
    }
181
182
    /**
183 1
     * @return int|null
184
     */
185 1
    public function getProximityAlertRadius()
186
    {
187
        return $this->proximityAlertRadius;
188
    }
189
190
    /**
191 3
     * @param int $proximityAlertRadius
192
     * @return void
193 3
     */
194 3
    public function setProximityAlertRadius($proximityAlertRadius)
195
    {
196
        $this->proximityAlertRadius = $proximityAlertRadius;
197
    }
198
}
199