Completed
Push — master ( 7d37a2...fea370 )
by Nikolay
06:21
created

EditMessageLiveLocationMethod   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 0
loc 68
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A createInline() 0 6 1
A create() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method;
6
7
use Greenplugin\TelegramBot\Method\Traits\EditMessageVariablesTrait;
8
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
9
10
/**
11
 * Class EditMessageLiveLocationMethod.
12
 *
13
 * @see https://core.telegram.org/bots/api#editmessagelivelocation
14
 */
15
class EditMessageLiveLocationMethod
16
{
17
    use EditMessageVariablesTrait;
18
    use FillFromArrayTrait;
19
    /**
20
     * Latitude of the location.
21
     *
22
     * @var float
23
     */
24
    public $latitude;
25
26
    /**
27
     * Longitude of the location.
28
     *
29
     * @var float
30
     */
31
    public $longitude;
32
33
    /**
34
     * @param float      $latitude
35
     * @param float      $longitude
36
     * @param array|null $data
37
     *
38
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
39
     */
40
    public function __construct(float $latitude, float $longitude, array $data = null)
41
    {
42
        $this->$latitude = $latitude;
43
        $this->longitude = $longitude;
44
        if ($data) {
45
            $this->fill($data);
46
        }
47
    }
48
49
    /**
50
     * @param int|string $chatId
51
     * @param float      $latitude
52
     * @param float      $longitude
53
     * @param array|null $data
54
     *
55
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
56
     *
57
     * @return EditMessageLiveLocationMethod
58
     */
59
    public static function create($chatId, float $latitude, float $longitude, array $data = null): EditMessageLiveLocationMethod
60
    {
61
        $method = new self($latitude, $longitude, $data);
62
        $method->chatId = $chatId;
63
64
        return $method;
65
    }
66
67
    /**
68
     * @param string     $inlineMessageId
69
     * @param float      $latitude
70
     * @param float      $longitude
71
     * @param array|null $data
72
     *
73
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
74
     *
75
     * @return EditMessageLiveLocationMethod
76
     */
77
    public static function createInline(string $inlineMessageId, float $latitude, float $longitude, array $data = null): EditMessageLiveLocationMethod
78
    {
79
        $method = new self($latitude, $longitude, $data);
80
        $method->inlineMessageId = $inlineMessageId;
81
82
        return $method;
83
    }
84
}
85