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

GetUpdatesMethod::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

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