MessageEntity   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 212
Duplicated Lines 0 %

Test Coverage

Coverage 91.43%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 14
eloc 47
c 1
b 0
f 1
dl 0
loc 212
ccs 32
cts 35
cp 0.9143
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A setType() 0 3 1
A getOffset() 0 3 1
A getType() 0 3 1
A setLanguage() 0 3 1
A setCustomEmojiId() 0 3 1
A getCustomEmojiId() 0 3 1
A getLength() 0 3 1
A setUser() 0 3 1
A getLanguage() 0 3 1
A setLength() 0 3 1
A setUrl() 0 3 1
A getUser() 0 3 1
A setOffset() 0 3 1
A getUrl() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: iGusev
5
 * Date: 13/04/16
6
 * Time: 04:10
7
 */
8
9
namespace TelegramBot\Api\Types;
10
11
use TelegramBot\Api\BaseType;
12
use TelegramBot\Api\TypeInterface;
13
14
/**
15
 * class MessageEntity.
16
 * This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
17
 *
18
 * @package TelegramBot\Api\Types
19
 */
20
class MessageEntity extends BaseType implements TypeInterface
21
{
22
    const TYPE_MENTION = 'mention';
23
    const TYPE_HASHTAG = 'hashtag';
24
    const TYPE_CASHTAG = 'cashtag';
25
    const TYPE_BOT_COMMAND = 'bot_command';
26
    const TYPE_URL = 'url';
27
    const TYPE_EMAIL = 'email';
28
    const TYPE_PHONE_NUMBER = 'phone_number';
29
    const TYPE_BOLD = 'bold';
30
    const TYPE_ITALIC = 'italic';
31
    const TYPE_UNDERLINE = 'underline';
32
    const TYPE_STRIKETHROUGH = 'strikethrough';
33
    const TYPE_CODE = 'code';
34
    const TYPE_PRE = 'pre';
35
    const TYPE_TEXT_LINK = 'text_link';
36
    const TYPE_TEXT_MENTION = 'text_mention';
37
    const TYPE_CUSTOM_EMOJI = 'custom_emoji';
38
39
    /**
40
     * {@inheritdoc}
41
     *
42
     * @var array
43
     */
44
    protected static $requiredParams = ['type', 'offset', 'length'];
45
46
    /**
47
     * {@inheritdoc}
48
     *
49
     * @var array
50
     */
51
    protected static $map = [
52
        'type' => true,
53
        'offset' => true,
54
        'length' => true,
55
        'url' => true,
56
        'user' => User::class,
57
        'language' => true,
58
        'custom_emoji_id' => true,
59
    ];
60
61
    /**
62
     * Type of the entity.
63
     * One of mention (@username), hashtag (#hashtag), cashtag ($USD), bot_command, url, email, phone_number,
64
     * bold (bold text), italic (italic text), underline (underlined text), strikethrough (strikethrough text),
65
     * code (monowidth string), pre (monowidth block), text_link (for clickable text URLs),
66
     * text_mention (for users without usernames)
67
     *
68
     * @var string
69
     */
70
    protected $type;
71
72
    /**
73
     * Offset in UTF-16 code units to the start of the entity
74
     *
75
     * @var int
76
     */
77
    protected $offset;
78
79
    /**
80
     * Length of the entity in UTF-16 code units
81
     *
82
     * @var int
83
     */
84
    protected $length;
85
86
    /**
87
     * Optional. For “text_link” only, url that will be opened after user taps on the text
88
     *
89
     * @var string|null
90
     */
91
    protected $url;
92
93
    /**
94
     * Optional. For “text_mention” only, the mentioned user
95
     *
96
     * @var User|null
97
     */
98
    protected $user;
99
100
    /**
101
     * Optional. For “pre” only, the programming language of the entity text
102
     *
103
     * @var string|null
104
     */
105
    protected $language;
106
107
    /**
108
     * Optional. For “custom_emoji” only, unique identifier of the custom emoji.
109
     * Use getCustomEmojiStickers to get full information about the sticker
110
     *
111
     * @var string|null
112
     */
113
    protected $customEmojiId;
114
115
    /**
116
     * @return string
117
     */
118
    public function getType()
119 2
    {
120
        return $this->type;
121 2
    }
122
123
    /**
124
     * @param string $type
125
     * @return void
126
     */
127 3
    public function setType($type)
128
    {
129 3
        $this->type = $type;
130 3
    }
131
132
    /**
133
     * @return int
134
     */
135 2
    public function getOffset()
136
    {
137 2
        return $this->offset;
138
    }
139
140
    /**
141
     * @param int $offset
142
     * @return void
143 3
     */
144
    public function setOffset($offset)
145 3
    {
146 3
        $this->offset = $offset;
147
    }
148
149
    /**
150
     * @return int
151 2
     */
152
    public function getLength()
153 2
    {
154
        return $this->length;
155
    }
156
157
    /**
158
     * @param int $length
159 3
     * @return void
160
     */
161 3
    public function setLength($length)
162 3
    {
163
        $this->length = $length;
164
    }
165
166
    /**
167 2
     * @return null|string
168
     */
169 2
    public function getUrl()
170
    {
171
        return $this->url;
172
    }
173
174
    /**
175
     * @param string $url
176
     * @return void
177
     */
178
    public function setUrl($url)
179
    {
180
        $this->url = $url;
181
    }
182
183 2
    /**
184
     * @return User|null
185 2
     */
186
    public function getUser()
187
    {
188
        return $this->user;
189
    }
190
191 1
    /**
192
     * @param User $user
193 1
     * @return void
194 1
     */
195
    public function setUser($user)
196
    {
197
        $this->user = $user;
198
    }
199 2
200
    /**
201 2
     * @return null|string
202
     */
203
    public function getLanguage()
204
    {
205
        return $this->language;
206
    }
207 1
208
    /**
209 1
     * @param string $language
210 1
     * @return void
211
     */
212
    public function setLanguage($language)
213
    {
214
        $this->language = $language;
215 1
    }
216
217 1
    /**
218
     * @return null|string
219
     */
220
    public function getCustomEmojiId()
221
    {
222
        return $this->customEmojiId;
223 1
    }
224
225 1
    /**
226 1
     * @param string $customEmojiId
227
     * @return void
228
     */
229
    public function setCustomEmojiId($customEmojiId)
230
    {
231
        $this->customEmojiId = $customEmojiId;
232
    }
233
}
234