Passed
Push — master ( a7c7c9...5f40ba )
by Eldar
02:11 queued 11s
created

MessageEntity::getOffset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
class MessageEntity extends BaseType implements TypeInterface
15
{
16
17
    const TYPE_MENTION = 'mention';
18
    const TYPE_HASHTAG = 'hashtag';
19
    const TYPE_CASHTAG = 'cashtag';
20
    const TYPE_BOT_COMMAND = 'bot_command';
21
    const TYPE_URL = 'url';
22
    const TYPE_EMAIL = 'email';
23
    const TYPE_PHONE_NUMBER = 'phone_number';
24
    const TYPE_BOLD = 'bold';
25
    const TYPE_ITALIC = 'italic';
26
    const TYPE_UNDERLINE = 'underline';
27
    const TYPE_STRIKETHROUGH = 'strikethrough';
28
    const TYPE_CODE = 'code';
29
    const TYPE_PRE = 'pre';
30
    const TYPE_TEXT_LINK = 'text_link';
31
    const TYPE_TEXT_MENTION = 'text_mention';
32
33
    /**
34
     * {@inheritdoc}
35
     *
36
     * @var array
37
     */
38
    static protected $requiredParams = ['type', 'offset', 'length'];
39
40
    /**
41
     * {@inheritdoc}
42
     *
43
     * @var array
44
     */
45
    static protected $map = [
46
        'type' => true,
47
        'offset' => true,
48
        'length' => true,
49
        'url' => true,
50
        'user' => User::class,
51
        'language' => true,
52
    ];
53
54
    /**
55
     * Type of the entity.
56
     * One of mention (@username), hashtag (#hashtag), cashtag ($USD), bot_command, url, email, phone_number,
57
     * bold (bold text), italic (italic text), underline (underlined text), strikethrough (strikethrough text),
58
     * code (monowidth string), pre (monowidth block), text_link (for clickable text URLs),
59
     * text_mention (for users without usernames)
60
     *
61
     * @var string
62
     */
63
    protected $type;
64
65
    /**
66
     * Offset in UTF-16 code units to the start of the entity
67
     *
68
     * @var int
69
     */
70
    protected $offset;
71
72
    /**
73
     * Length of the entity in UTF-16 code units
74
     *
75
     * @var int
76
     */
77
    protected $length;
78
79
    /**
80
     * Optional. For “text_link” only, url that will be opened after user taps on the text
81
     *
82
     * @var string
83
     */
84
    protected $url;
85
86
    /**
87
     * Optional. For “text_mention” only, the mentioned user
88
     *
89
     * @var User
90
     */
91
    protected $user;
92
93
    /**
94
     * Optional. For “pre” only, the programming language of the entity text
95
     *
96
     * @var string
97
     */
98
    protected $language;
99
100
    /**
101
     * @return string
102
     */
103 2
    public function getType()
104
    {
105 2
        return $this->type;
106
    }
107
108
    /**
109
     * @param string $type
110
     */
111 3
    public function setType($type)
112
    {
113 3
        $this->type = $type;
114 3
    }
115
116
    /**
117
     * @return int
118
     */
119 2
    public function getOffset()
120
    {
121 2
        return $this->offset;
122
    }
123
124
    /**
125
     * @param int $offset
126
     */
127 3
    public function setOffset($offset)
128
    {
129 3
        $this->offset = $offset;
130 3
    }
131
132
    /**
133
     * @return int
134
     */
135 2
    public function getLength()
136
    {
137 2
        return $this->length;
138
    }
139
140
    /**
141
     * @param int $length
142
     */
143 3
    public function setLength($length)
144
    {
145 3
        $this->length = $length;
146 3
    }
147
148
    /**
149
     * @return string
150
     */
151 2
    public function getUrl()
152
    {
153 2
        return $this->url;
154
    }
155
156
    /**
157
     * @param string $url
158
     */
159
    public function setUrl($url)
160
    {
161
        $this->url = $url;
162
    }
163
164
    /**
165
     * @return User
166
     */
167 2
    public function getUser()
168
    {
169 2
        return $this->user;
170
    }
171
172
    /**
173
     * @param User $user
174
     */
175 1
    public function setUser($user)
176
    {
177 1
        $this->user = $user;
178 1
    }
179
180
    /**
181
     * @return string
182
     */
183 2
    public function getLanguage()
184
    {
185 2
        return $this->language;
186
    }
187
188
    /**
189
     * @param string $language
190
     */
191 1
    public function setLanguage($language)
192
    {
193 1
        $this->language = $language;
194 1
    }
195
}
196