Completed
Push — master ( 62cb7b...4b7fdd )
by Nikolay
02:34
created

SendLocationMethod::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 4
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
8
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
9
10
/**
11
 * Class SendLocationMethod.
12
 *
13
 * @see https://core.telegram.org/bots/api#sendlocation
14
 */
15
class SendLocationMethod
16
{
17
    use FillFromArrayTrait;
18
    use SendToChatVariablesTrait;
19
20
    /**
21
     * Latitude of the location.
22
     *
23
     * @var float
24
     */
25
    public $latitude;
26
27
    /**
28
     * Longitude of the location.
29
     *
30
     * @var float
31
     */
32
    public $longitude;
33
34
    /**
35
     * Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400.
36
     *
37
     * @var int|null
38
     */
39
    public $livePeriod;
40
41
    /**
42
     * @param int|string $chatId
43
     * @param float      $latitude
44
     * @param float      $longitude
45
     * @param array|null $data
46
     *
47
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
48
     *
49
     * @return SendLocationMethod
50
     */
51 2
    public static function create($chatId, float $latitude, float $longitude, array $data = null): SendLocationMethod
52
    {
53 2
        $instance = new static();
54 2
        $instance->chatId = $chatId;
55 2
        $instance->latitude = $latitude;
56 2
        $instance->longitude = $longitude;
57 2
        if ($data) {
58 1
            $instance->fill($data);
59
        }
60
61 2
        return $instance;
62
    }
63
}
64