Passed
Push — master ( 3bfee0...112fc6 )
by Nikolay
02:02
created

GetUpdatesMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 61
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\HasUpdateTypeVariableInterface;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
10
/**
11
 * Class GetUpdatesMethod.
12
 *
13
 * @see https://core.telegram.org/bots/api#getupdates
14
 */
15
class GetUpdatesMethod implements HasUpdateTypeVariableInterface
16
{
17
    use FillFromArrayTrait;
18
19
    /**
20
     * Optional. Identifier of the first update to be returned.
21
     * Must be greater by one than the highest among the identifiers of previously received updates.
22
     * By default, updates starting with the earliest unconfirmed update are returned.
23
     * An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id.
24
     * The negative offset can be specified to retrieve updates starting from -offset update
25
     * from the end of the updates queue. All previous updates will forgotten.
26
     *
27
     * @var int|null
28
     */
29
    public $offset;
30
31
    /**
32
     * Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
33
     *
34
     * @var int|null
35
     */
36
    public $limit;
37
38
    /**
39
     * Optional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling.
40
     * Should be positive, short polling should be used for testing purposes only.
41
     *
42
     * @var int|null
43
     */
44
    public $timeout;
45
46
    /**
47
     * Optional. List the types of updates you want your bot to receive.
48
     * For example, specify [“message”, “edited_channel_post”, “callback_query”]
49
     * to only receive updates of these types.
50
     * See Update for a complete list of available update types.
51
     * Specify an empty list to receive all updates regardless of type (default).
52
     * If not specified, the previous setting will be used.
53
     *
54
     * Please note that this parameter doesn't affect updates created before the call to the getUpdates,
55
     * so unwanted updates may be received for a short period of time.
56
     *
57
     * @var string[]|null
58
     */
59
    public $allowedUpdates;
60
61
    /**
62
     * @param array|null $data
63
     *
64
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
65
     *
66
     * @return GetUpdatesMethod
67
     */
68 6
    public static function create(array $data = null): GetUpdatesMethod
69
    {
70 6
        $instance = new static();
71 6
        if ($data) {
72 3
            $instance->fill($data);
73
        }
74
75 6
        return $instance;
76
    }
77
}
78