EditMessageLiveLocationMethod   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 0
loc 76
ccs 0
cts 27
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 10 1
A create() 0 10 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(
60
        $chatId,
61
        float $latitude,
62
        float $longitude,
63
        array $data = null
64
    ): EditMessageLiveLocationMethod {
65
        $method = new self($latitude, $longitude, $data);
66
        $method->chatId = $chatId;
67
68
        return $method;
69
    }
70
71
    /**
72
     * @param string     $inlineMessageId
73
     * @param float      $latitude
74
     * @param float      $longitude
75
     * @param array|null $data
76
     *
77
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
78
     *
79
     * @return EditMessageLiveLocationMethod
80
     */
81
    public static function createInline(
82
        string $inlineMessageId,
83
        float $latitude,
84
        float $longitude,
85
        array $data = null
86
    ): EditMessageLiveLocationMethod {
87
        $method = new self($latitude, $longitude, $data);
88
        $method->inlineMessageId = $inlineMessageId;
89
90
        return $method;
91
    }
92
}
93