Passed
Pull Request — master (#408)
by Alexander
01:42
created

MessageEntity::setOffset()   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 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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
23
    const TYPE_MENTION = 'mention';
24
    const TYPE_HASHTAG = 'hashtag';
25
    const TYPE_CASHTAG = 'cashtag';
26
    const TYPE_BOT_COMMAND = 'bot_command';
27
    const TYPE_URL = 'url';
28
    const TYPE_EMAIL = 'email';
29
    const TYPE_PHONE_NUMBER = 'phone_number';
30
    const TYPE_BOLD = 'bold';
31
    const TYPE_ITALIC = 'italic';
32
    const TYPE_UNDERLINE = 'underline';
33
    const TYPE_STRIKETHROUGH = 'strikethrough';
34
    const TYPE_CODE = 'code';
35
    const TYPE_PRE = 'pre';
36
    const TYPE_TEXT_LINK = 'text_link';
37
    const TYPE_TEXT_MENTION = 'text_mention';
38
    const TYPE_CUSTOM_EMOJI = 'custom_emoji';
39
40
    /**
41
     * {@inheritdoc}
42
     *
43
     * @var array
44
     */
45
    static protected $requiredParams = ['type', 'offset', 'length'];
46
47
    /**
48
     * {@inheritdoc}
49
     *
50
     * @var array
51
     */
52
    static protected $map = [
53
        'type' => true,
54
        'offset' => true,
55
        'length' => true,
56
        'url' => true,
57
        'user' => User::class,
58
        'language' => true,
59
        'custom_emoji_id' => true,
60
    ];
61
62
    /**
63
     * Type of the entity.
64
     * One of mention (@username), hashtag (#hashtag), cashtag ($USD), bot_command, url, email, phone_number,
65
     * bold (bold text), italic (italic text), underline (underlined text), strikethrough (strikethrough text),
66
     * code (monowidth string), pre (monowidth block), text_link (for clickable text URLs),
67
     * text_mention (for users without usernames)
68
     *
69
     * @var string
70
     */
71
    protected $type;
72
73
    /**
74
     * Offset in UTF-16 code units to the start of the entity
75
     *
76
     * @var int
77
     */
78
    protected $offset;
79
80
    /**
81
     * Length of the entity in UTF-16 code units
82
     *
83
     * @var int
84
     */
85
    protected $length;
86
87
    /**
88
     * Optional. For “text_link” only, url that will be opened after user taps on the text
89
     *
90
     * @var string
91
     */
92
    protected $url;
93
94
    /**
95
     * Optional. For “text_mention” only, the mentioned user
96
     *
97
     * @var User
98
     */
99
    protected $user;
100
101
    /**
102
     * Optional. For “pre” only, the programming language of the entity text
103
     *
104
     * @var string
105
     */
106
    protected $language;
107
108
    /**
109
     * Optional. For “custom_emoji” only, unique identifier of the custom emoji.
110
     * Use getCustomEmojiStickers to get full information about the sticker
111
     *
112
     * @var string
113
     */
114
    protected $customEmojiId;
115
116
    /**
117
     * @return string
118
     */
119 2
    public function getType()
120
    {
121 2
        return $this->type;
122
    }
123
124
    /**
125
     * @param string $type
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
     */
143 3
    public function setOffset($offset)
144
    {
145 3
        $this->offset = $offset;
146 3
    }
147
148
    /**
149
     * @return int
150
     */
151 2
    public function getLength()
152
    {
153 2
        return $this->length;
154
    }
155
156
    /**
157
     * @param int $length
158
     */
159 3
    public function setLength($length)
160
    {
161 3
        $this->length = $length;
162 3
    }
163
164
    /**
165
     * @return string
166
     */
167 2
    public function getUrl()
168
    {
169 2
        return $this->url;
170
    }
171
172
    /**
173
     * @param string $url
174
     */
175
    public function setUrl($url)
176
    {
177
        $this->url = $url;
178
    }
179
180
    /**
181
     * @return User
182
     */
183 2
    public function getUser()
184
    {
185 2
        return $this->user;
186
    }
187
188
    /**
189
     * @param User $user
190
     */
191 1
    public function setUser($user)
192
    {
193 1
        $this->user = $user;
194 1
    }
195
196
    /**
197
     * @return string
198
     */
199 2
    public function getLanguage()
200
    {
201 2
        return $this->language;
202
    }
203
204
    /**
205
     * @param string $language
206
     */
207 1
    public function setLanguage($language)
208
    {
209 1
        $this->language = $language;
210 1
    }
211
212
    /**
213
     * @return string
214
     */
215 1
    public function getCustomEmojiId()
216
    {
217 1
        return $this->customEmojiId;
218
    }
219
220
    /**
221
     * @param string $customEmojiId
222
     */
223 1
    public function setCustomEmojiId($customEmojiId)
224
    {
225 1
        $this->customEmojiId = $customEmojiId;
226 1
    }
227
}
228