SendLocationMethod   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 16
dl 0
loc 66
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
10
11
/**
12
 * Class SendLocationMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#sendlocation
15
 */
16
class SendLocationMethod implements SendMethodAliasInterface
17
{
18
    use FillFromArrayTrait;
19
    use SendToChatVariablesTrait;
20
21
    /**
22
     * Latitude of the location.
23
     *
24
     * @var float
25
     */
26
    public $latitude;
27
28
    /**
29
     * Longitude of the location.
30
     *
31
     * @var float
32
     */
33
    public $longitude;
34
35
    /**
36
     * Optional. The radius of uncertainty for the location, measured in meters; 0-1500.
37
     *
38
     * @var float|int|null
39
     */
40
    public $horizontalAccuracy;
41
42
    /**
43
     * Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400.
44
     *
45
     * @var int|null
46
     */
47
    public $livePeriod;
48
49
    /**
50
     * Optional. For live locations, a direction in which the user is moving, in degrees.
51
     * Must be between 1 and 360 if specified.
52
     *
53
     * @var int|null
54
     */
55
    public $heading;
56
57
    /**
58
     * Optional. For live locations, a maximum distance
59
     * for proximity alerts about approaching another chat member, in meters.
60
     * Must be between 1 and 100000 if specified.
61
     *
62
     * @var int|null
63
     */
64
    public $proximityAlertRadius;
65
66
    /**
67
     * @param int|string $chatId
68
     *
69
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
70
     */
71 2
    public static function create($chatId, float $latitude, float $longitude, array $data = null): SendLocationMethod
72
    {
73 2
        $instance = new static();
74 2
        $instance->chatId = $chatId;
75 2
        $instance->latitude = $latitude;
76 2
        $instance->longitude = $longitude;
77 2
        if ($data) {
78 1
            $instance->fill($data);
79
        }
80
81 2
        return $instance;
82
    }
83
}
84