Completed
Push — master ( 4b7fdd...026556 )
by Nikolay
02:45
created

SetWebhookMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 60
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 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
use TgBotApi\BotApiBase\Type\InputFileType;
10
11
/**
12
 * Class SetWebhookMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#setwebhook
15
 * @see https://core.telegram.org/bots/webhooks
16
 */
17
class SetWebhookMethod implements HasUpdateTypeVariableInterface
18
{
19
    use FillFromArrayTrait;
20
21
    /**
22
     * HTTPS url to send updates to. Use an empty string to remove webhook integration.
23
     *
24
     * @var string
25
     */
26
    public $url;
27
28
    /**
29
     * Optional. Upload your public key certificate so that the root certificate in use can be checked.
30
     *
31
     * @see https://core.telegram.org/bots/self-signed
32
     *
33
     * @var InputFileType|null
34
     */
35
    public $certificate;
36
37
    /**
38
     * Optional    Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100.
39
     * Defaults to 40. Use lower values to limit the load on your bot‘s server,
40
     * and higher values to increase your bot’s throughput.
41
     *
42
     * @var int|null
43
     */
44
    public $maxConnections;
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”] to only receive updates of these types.
49
     * See Update for a complete list of available update types.
50
     * Specify an empty list to receive all updates regardless of type (default).
51
     * If not specified, the previous setting will be used.
52
     *
53
     * Please note that this parameter doesn't affect updates created before the call to the setWebhook,
54
     * so unwanted updates may be received for a short period of time.
55
     *
56
     * @var string[]|null
57
     */
58
    public $allowedUpdates;
59
60
    /**
61
     * @param string     $url
62
     * @param array|null $data
63
     *
64
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
65
     *
66
     * @return SetWebhookMethod
67
     */
68 1
    public static function create(string $url, array $data = null): SetWebhookMethod
69
    {
70 1
        $instance = new static();
71 1
        $instance->url = $url;
72 1
        if ($data) {
73 1
            $instance->fill($data);
74
        }
75
76 1
        return $instance;
77
    }
78
}
79