Completed
Push — master ( 1ab7f6...5e4939 )
by Camilo
01:36
created

Update   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
dl 0
loc 105
ccs 18
cts 21
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 12
lcom 0
cbo 9

1 Method

Rating   Name   Duplication   Size   Complexity  
C mapSubObjects() 0 26 12
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Types;
6
7
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
8
use unreal4u\TelegramAPI\Telegram\Types\Inline\ChosenResult;
9
use unreal4u\TelegramAPI\Telegram\Types\Inline\Query;
10
11
/**
12
 * This object represents an incoming update.
13
 * At most one of the optional parameters can be present in any given update.
14
 *
15
 * Objects defined as-is June 2020, Bot API v4.9
16
 *
17
 * @see https://core.telegram.org/bots/api#update
18
 */
19
class Update extends TelegramTypes
20
{
21
    /**
22
     * The update‘s unique identifier. Update identifiers start from a certain positive number and increase
23
     * sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated
24
     * updates or to restore the correct update sequence, should they get out of order.
25
     * @var int
26
     */
27
    public $update_id = 0;
28
29
    /**
30
     * Optional. New incoming message of any kind — text, photo, sticker, etc.
31
     * @var Message
32
     */
33
    public $message;
34
35
    /**
36
     * Optional. New version of a message that is known to the bot and was edited
37
     * @var Message
38
     */
39
    public $edited_message;
40
41
    /**
42
     * Optional. New incoming channel post of any kind — text, photo, sticker, etc.
43
     * @var Message
44
     */
45
    public $channel_post;
46
47
    /**
48
     * Optional. New version of a channel post that is known to the bot and was edited
49
     * @var Message
50
     */
51
    public $edited_channel_post;
52
53
    /**
54
     * Optional. New incoming inline query
55
     * @var Query
56
     */
57
    public $inline_query;
58
59
    /**
60
     * Optional. The result of a inline query that was chosen by a user and sent to their chat partner
61
     * @var ChosenResult
62
     */
63
    public $chosen_inline_result;
64
65
    /**
66
     * Optional. New incoming callback query
67
     * @var CallbackQuery
68
     */
69
    public $callback_query;
70
71
    /**
72
     * Optional. New incoming shipping query. Only for invoices with flexible price
73
     * @var ShippingQuery
74
     */
75
    public $shipping_query;
76
77
    /**
78
     * Optional. New incoming pre-checkout query. Contains full information about checkout
79
     * @var PreCheckoutQuery
80
     */
81
    public $pre_checkout_query;
82
83
    /**
84
     * Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot
85
     * @var Poll
86
     */
87
    public $poll;
88
89
    /**
90
     * Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were
91
     * sent by the bot itself.
92
     *
93
     * @var PollAnswer
94
     */
95
    public $poll_answer;
96
97 7
    protected function mapSubObjects(string $key, array $data): TelegramTypes
98
    {
99
        switch ($key) {
100 7
            case 'message':
101 5
            case 'edited_message':
102 5
            case 'channel_post':
103 5
            case 'edited_channel_post':
104 3
                return new Message($data, $this->logger);
105 5
            case 'inline_query':
106 1
                return new Query($data, $this->logger);
107 4
            case 'chosen_inline_result':
108 1
                return new ChosenResult($data, $this->logger);
109 3
            case 'callback_query':
110 1
                return new CallbackQuery($data, $this->logger);
111 2
            case 'shipping_query':
112
                return new ShippingQuery($data, $this->logger);
113 2
            case 'pre_checkout_query':
114 1
                return new PreCheckoutQuery($data, $this->logger);
115 1
            case 'poll':
116
                return new Poll($data, $this->logger);
117 1
            case 'poll_answer':
118
                return new PollAnswer($data, $this->logger);
119
        }
120
121 1
        return parent::mapSubObjects($key, $data);
122
    }
123
}
124