Test Failed
Pull Request — master (#306)
by Eldar
03:11
created

Location::getLivePeriod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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
    static protected $requiredParams = ['latitude', 'longitude'];
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @var array
28
     */
29
    static protected $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
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
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
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
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 float $latitude
92
     *
93
     * @throws InvalidArgumentException
94
     */
95 7
    public function setLatitude($latitude)
96
    {
97 7
        if (is_float($latitude)) {
98 6
            $this->latitude = $latitude;
99 6
        } else {
100 1
            throw new InvalidArgumentException();
101
        }
102 6
    }
103
104
    /**
105
     * @return float
106
     */
107 1
    public function getLongitude()
108
    {
109 1
        return $this->longitude;
110
    }
111
112
    /**
113
     * @param float $longitude
114
     *
115
     * @throws InvalidArgumentException
116
     */
117 7
    public function setLongitude($longitude)
118
    {
119 7
        if (is_float($longitude)) {
120 6
            $this->longitude = $longitude;
121 6
        } else {
122 1
            throw new InvalidArgumentException();
123
        }
124 6
    }
125
126
    /**
127
     * @return float
128
     */
129 1
    public function getHorizontalAccuracy()
130
    {
131 1
        return $this->horizontalAccuracy;
132
    }
133
134
    /**
135
     * @param float $horizontalAccuracy
136
     *
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
150
     */
151 1
    public function getLivePeriod()
152
    {
153 1
        return $this->livePeriod;
154
    }
155
156
    /**
157
     * @param int $livePeriod
158
     */
159 3
    public function setLivePeriod($livePeriod)
160
    {
161 3
        $this->livePeriod = $livePeriod;
162 3
    }
163
164
    /**
165
     * @return int
166
     */
167 1
    public function getHeading()
168
    {
169 1
        return $this->heading;
170
    }
171
172
    /**
173
     * @param int $heading
174
     */
175 3
    public function setHeading($heading)
176
    {
177 3
        $this->heading = $heading;
178 3
    }
179
180
    /**
181
     * @return int
182
     */
183 1
    public function getProximityAlertRadius()
184
    {
185 1
        return $this->proximityAlertRadius;
186
    }
187
188
    /**
189
     * @param int $proximityAlertRadius
190
     */
191 3
    public function setProximityAlertRadius($proximityAlertRadius)
192
    {
193 3
        $this->proximityAlertRadius = $proximityAlertRadius;
194 3
    }
195
}
196