Completed
Push — master ( d04b6a...4e4c0e )
by Nikolay
03:14
created

EditMessageLiveLocationMethod   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 20
dl 0
loc 73
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 17 2
A createInline() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\EditMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\EditMessageVariablesTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
11
/**
12
 * Class EditMessageLiveLocationMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#editmessagelivelocation
15
 */
16
class EditMessageLiveLocationMethod implements EditMethodAliasInterface
17
{
18
    use EditMessageVariablesTrait;
19
    use FillFromArrayTrait;
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
     * @param int|string $chatId
36
     * @param int        $messageId
37
     * @param float      $latitude
38
     * @param float      $longitude
39
     * @param array|null $data
40
     *
41
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
42
     *
43
     * @return EditMessageLiveLocationMethod
44
     */
45 1
    public static function create(
46
        $chatId,
47
        int $messageId,
48
        float $latitude,
49
        float $longitude,
50
        array $data = null
51
    ): EditMessageLiveLocationMethod {
52 1
        $instance = new static();
53 1
        $instance->chatId = $chatId;
54 1
        $instance->messageId = $messageId;
55 1
        $instance->latitude = $latitude;
56 1
        $instance->longitude = $longitude;
57 1
        if ($data) {
58 1
            $instance->fill($data, ['chatId', 'messageId', 'latitude', 'longitude', 'inlineMessageId']);
59
        }
60
61 1
        return $instance;
62
    }
63
64
    /**
65
     * @param string     $inlineMessageId
66
     * @param float      $latitude
67
     * @param float      $longitude
68
     * @param array|null $data
69
     *
70
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
71
     *
72
     * @return EditMessageLiveLocationMethod
73
     */
74 1
    public static function createInline(
75
        string $inlineMessageId,
76
        float $latitude,
77
        float $longitude,
78
        array $data = null
79
    ): EditMessageLiveLocationMethod {
80 1
        $instance = new static();
81 1
        $instance->latitude = $latitude;
82 1
        $instance->longitude = $longitude;
83 1
        $instance->inlineMessageId = $inlineMessageId;
84 1
        if ($data) {
85 1
            $instance->fill($data, ['chatId', 'latitude', 'longitude', 'inlineMessageId']);
86
        }
87
88 1
        return $instance;
89
    }
90
}
91