Passed
Pull Request — master (#62)
by
unknown
11:14
created

GetMethodTrait::getChatMenuButton()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Traits;
6
7
use TgBotApi\BotApiBase\Exception\ResponseException;
8
use TgBotApi\BotApiBase\Method\GetChatAdministratorsMethod;
9
use TgBotApi\BotApiBase\Method\GetChatMemberMethod;
10
use TgBotApi\BotApiBase\Method\GetChatMembersCountMethod;
11
use TgBotApi\BotApiBase\Method\GetChatMethod;
12
use TgBotApi\BotApiBase\Method\GetChatMenuButtonMethod;
13
use TgBotApi\BotApiBase\Method\GetFileMethod;
14
use TgBotApi\BotApiBase\Method\GetGameHighScoresMethod;
15
use TgBotApi\BotApiBase\Method\GetMeMethod;
16
use TgBotApi\BotApiBase\Method\GetMyCommandsMethod;
17
use TgBotApi\BotApiBase\Method\GetStickerSetMethod;
18
use TgBotApi\BotApiBase\Method\GetUpdatesMethod;
19
use TgBotApi\BotApiBase\Method\GetUserProfilePhotosMethod;
20
use TgBotApi\BotApiBase\Method\GetWebhookInfoMethod;
21
use TgBotApi\BotApiBase\Method\Interfaces\MethodInterface;
22
use TgBotApi\BotApiBase\Type\BotCommandType;
23
use TgBotApi\BotApiBase\Type\ChatMemberType;
24
use TgBotApi\BotApiBase\Type\ChatType;
25
use TgBotApi\BotApiBase\Type\FileType;
26
use TgBotApi\BotApiBase\Type\GameHighScoreType;
27
use TgBotApi\BotApiBase\Type\MenuButtonType;
28
use TgBotApi\BotApiBase\Type\StickerSetType;
29
use TgBotApi\BotApiBase\Type\UpdateType;
30
use TgBotApi\BotApiBase\Type\UserProfilePhotosType;
31
use TgBotApi\BotApiBase\Type\UserType;
32
use TgBotApi\BotApiBase\Type\WebhookInfoType;
33
34
trait GetMethodTrait
35
{
36
    /**
37
     * @param $type
38
     *
39
     * @throws ResponseException
40
     *
41
     * @return mixed
42
     */
43
    abstract public function call(MethodInterface $method, string $type = null);
44
45
    /**
46
     * @throws ResponseException
47
     *
48 2
     * @return UpdateType[]
49
     */
50 2
    public function getUpdates(GetUpdatesMethod $method): array
51
    {
52
        return $this->call($method, UpdateType::class . '[]');
53
    }
54
55
    /**
56 2
     * @throws ResponseException
57
     */
58 2
    public function getMe(GetMeMethod $method): UserType
59
    {
60
        return $this->call($method, UserType::class);
61
    }
62
63
    /**
64
     * @throws ResponseException
65
     *
66 1
     * @return BotCommandType[]
67
     */
68 1
    public function getMyCommands(GetMyCommandsMethod $method): array
69
    {
70
        return $this->call($method, BotCommandType::class . '[]');
71
    }
72
73
    /**
74 2
     * @throws ResponseException
75
     */
76 2
    public function getUserProfilePhotos(GetUserProfilePhotosMethod $method): UserProfilePhotosType
77
    {
78
        return $this->call($method, UserProfilePhotosType::class);
79
    }
80
81
    /**
82 1
     * @throws ResponseException
83
     */
84 1
    public function getWebhookInfo(GetWebhookInfoMethod $method): WebhookInfoType
85
    {
86
        return $this->call($method, WebhookInfoType::class);
87
    }
88
89
    /**
90 1
     * @throws ResponseException
91
     */
92 1
    public function getChatMembersCount(GetChatMembersCountMethod $method): int
93
    {
94
        return $this->call($method);
95
    }
96
97
    /**
98 2
     * @throws ResponseException
99
     */
100 2
    public function getChat(GetChatMethod $method): ChatType
101
    {
102
        return $this->call($method, ChatType::class);
103
    }
104
105
    /**
106
     * @throws ResponseException
107
     *
108 2
     * @return ChatMemberType[]
109
     */
110 2
    public function getChatAdministrators(GetChatAdministratorsMethod $method): array
111
    {
112
        return $this->call($method, ChatMemberType::class . '[]');
113
    }
114
115
    /**
116 2
     * @throws ResponseException
117
     */
118 2
    public function getChatMember(GetChatMemberMethod $method): ChatMemberType
119
    {
120
        return $this->call($method, ChatMemberType::class);
121
    }
122
123
    /**
124
     * @throws ResponseException
125
     */
126 2
    public function getChatMenuButton(GetChatMenuButtonMethod $method): MenuButtonType
127
    {
128 2
        return $this->call($method, MenuButtonType::class);
129
    }
130
131
    /**
132
     * @throws ResponseException
133
     *
134 1
     * @return GameHighScoreType[]
135
     */
136 1
    public function getGameHighScores(GetGameHighScoresMethod $method): array
137
    {
138
        return $this->call($method, GameHighScoreType::class . '[]');
139
    }
140
141
    /**
142 2
     * @throws ResponseException
143
     */
144 2
    public function getStickerSet(GetStickerSetMethod $method): StickerSetType
145
    {
146
        return $this->call($method, StickerSetType::class);
147
    }
148
149
    /**
150
     * @throws ResponseException
151
     */
152
    public function getFile(GetFileMethod $method): FileType
153
    {
154
        return $this->call($method, FileType::class);
155
    }
156
}
157