Completed
Push — master ( e9eebf...b866da )
by Gusev
03:01
created

Gif   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 185
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
c 1
b 0
f 0
lcom 0
cbo 1
dl 185
loc 185
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 20 20 1
A getGifUrl() 4 4 1
A setGifUrl() 4 4 1
A getGifWidth() 4 4 1
A setGifWidth() 4 4 1
A getGifHeight() 4 4 1
A setGifHeight() 4 4 1
A getThumbUrl() 4 4 1
A setThumbUrl() 4 4 1
A getCaption() 4 4 1
A setCaption() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace TelegramBot\Api\Types\Inline\QueryResult;
4
5
/**
6
 * Class InlineQueryResultGif
7
 * Represents a link to an animated GIF file.
8
 * By default, this animated GIF file will be sent by the user with optional caption.
9
 * Alternatively, you can provide message_text to send it instead of the animation.
10
 *
11
 * @package TelegramBot\Api\Types\Inline
12
 */
13 View Code Duplication
class Gif extends AbstractInlineQueryResult
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * {@inheritdoc}
17
     *
18
     * @var array
19
     */
20
    static protected $requiredParams = ['type', 'id', 'gif_url', 'thumb_url'];
21
22
    /**
23
     * {@inheritdoc}
24
     *
25
     * @var array
26
     */
27
    static protected $map = [
28
        'type' => true,
29
        'id' => true,
30
        'gif_url' => true,
31
        'gif_width' => true,
32
        'gif_height' => true,
33
        'thumb_url' => true,
34
        'title' => true,
35
        'caption' => true,
36
        'message_text' => true,
37
        'parse_mode' => true,
38
        'disable_web_page_preview' => true,
39
    ];
40
41
    /**
42
     * {@inheritdoc}
43
     *
44
     * @var string
45
     */
46
    protected $type = 'gif';
47
48
    /**
49
     * A valid URL for the GIF file. File size must not exceed 1MB
50
     *
51
     * @var string
52
     */
53
    protected $gifUrl;
54
55
    /**
56
     * Optional. Width of the GIF
57
     *
58
     * @var int
59
     */
60
    protected $gifWidth;
61
62
    /**
63
     * Optional. Height of the GIF
64
     *
65
     * @var int
66
     */
67
    protected $gifHeight;
68
69
    /**
70
     * URL of the static thumbnail for the result (jpeg or gif)
71
     *
72
     * @var string
73
     */
74
    protected $thumbUrl;
75
76
    /**
77
     * Optional. Caption of the GIF file to be sent, 0-200 characters
78
     *
79
     * @var string
80
     */
81
    protected $caption;
82
83
    /**
84
     * InlineQueryResultGif constructor.
85
     *
86
     * @param string $id
87
     * @param string $gifUrl
88
     * @param string $thumbUrl
89
     * @param int|null $gifWidth
90
     * @param int|null $gifHeight
91
     * @param string|null $caption
92
     * @param string|null $title
93
     * @param string|null $messageText
94
     * @param string|null $parseMode
95
     * @param bool|null $disableWebPagePreview
96
     */
97
    public function __construct(
98
        $id,
99
        $gifUrl,
100
        $thumbUrl,
101
        $gifWidth = null,
102
        $gifHeight = null,
103
        $caption = null,
104
        $title = null,
105
        $messageText = null,
106
        $parseMode = null,
107
        $disableWebPagePreview = null
108
    ) {
109
        parent::__construct($id, $title, $messageText, $parseMode, $disableWebPagePreview);
0 ignored issues
show
Bug introduced by
It seems like $messageText defined by parameter $messageText on line 105 can also be of type string; however, TelegramBot\Api\Types\In...ryResult::__construct() does only seem to accept object<TelegramBot\Api\T...putMessageContent>|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Bug introduced by
It seems like $parseMode defined by parameter $parseMode on line 106 can also be of type string; however, TelegramBot\Api\Types\In...ryResult::__construct() does only seem to accept object<TelegramBot\Api\T...ineKeyboardMarkup>|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Unused Code introduced by
The call to AbstractInlineQueryResult::__construct() has too many arguments starting with $disableWebPagePreview.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
110
111
        $this->gifUrl = $gifUrl;
112
        $this->thumbUrl = $thumbUrl;
113
        $this->gifWidth = $gifWidth;
114
        $this->gifHeight = $gifHeight;
115
        $this->caption = $caption;
116
    }
117
118
    /**
119
     * @return string
120
     */
121
    public function getGifUrl()
122
    {
123
        return $this->gifUrl;
124
    }
125
126
    /**
127
     * @param string $gifUrl
128
     */
129
    public function setGifUrl($gifUrl)
130
    {
131
        $this->gifUrl = $gifUrl;
132
    }
133
134
    /**
135
     * @return int
136
     */
137
    public function getGifWidth()
138
    {
139
        return $this->gifWidth;
140
    }
141
142
    /**
143
     * @param int $gifWidth
144
     */
145
    public function setGifWidth($gifWidth)
146
    {
147
        $this->gifWidth = $gifWidth;
148
    }
149
150
    /**
151
     * @return int
152
     */
153
    public function getGifHeight()
154
    {
155
        return $this->gifHeight;
156
    }
157
158
    /**
159
     * @param int $gifHeight
160
     */
161
    public function setGifHeight($gifHeight)
162
    {
163
        $this->gifHeight = $gifHeight;
164
    }
165
166
    /**
167
     * @return string
168
     */
169
    public function getThumbUrl()
170
    {
171
        return $this->thumbUrl;
172
    }
173
174
    /**
175
     * @param string $thumbUrl
176
     */
177
    public function setThumbUrl($thumbUrl)
178
    {
179
        $this->thumbUrl = $thumbUrl;
180
    }
181
182
    /**
183
     * @return string
184
     */
185
    public function getCaption()
186
    {
187
        return $this->caption;
188
    }
189
190
    /**
191
     * @param string $caption
192
     */
193
    public function setCaption($caption)
194
    {
195
        $this->caption = $caption;
196
    }
197
}
198