GetUpdatesMethod::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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