GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 64a210...2d6991 )
by Stan
02:42
created

InlineQuery::testPhoto()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 38
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 38
rs 8.8571
cc 2
eloc 24
nc 2
nop 0
1
<?php
2
3
namespace Teebot\Bot\Example\EntityEvent;
4
5
use Teebot\Command\AbstractEntityEvent;
6
use Teebot\Entity\Inline\InlineQueryResultArray;
7
use Teebot\Entity\Inline\InlineQueryResultArticle;
8
use Teebot\Entity\Inline\InlineQueryResultGif;
9
use Teebot\Entity\Inline\InlineQueryResultMpeg4Gif;
10
use Teebot\Entity\Inline\InlineQueryResultPhoto;
11
use Teebot\Entity\Inline\InlineQueryResultVideo;
12
use Teebot\Method\AnswerInlineQuery;
13
14
class InlineQuery extends AbstractEntityEvent
15
{
16
    /** @var \Teebot\Entity\Inline\InlineQuery $entity */
17
    protected $entity;
18
19
    public function run()
20
    {
21
        if (empty($this->entity->getQuery())) {
22
            return;
23
        }
24
25
        $query = strtolower($this->entity->getQuery());
0 ignored issues
show
Unused Code introduced by
$query is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26
27
        $this->testMpeg4Gif();
28
29
        return;
30
    }
31
32 View Code Duplication
    protected function testMpeg4Gif()
0 ignored issues
show
Duplication introduced by
This method 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...
33
    {
34
        $queryId = $this->entity->getId();
35
36
        $resultVideo = (new InlineQueryResultMpeg4Gif())
37
            ->setMpeg4Url('http://storage.akamai.coub.com/get/bucket:12.21/p/coub/simple/cw_file/0f18dd89e09/2d8508ac124aa6290da0e/muted_mp4_med_size_1409439085_muted_med.mp4')
38
            ->setMpeg4Width(335)
39
            ->setMpeg4Height(188)
40
            ->setId(1);
41
42
        $queryResultArray = (new InlineQueryResultArray())
43
            ->addEntity($resultVideo);
44
45
46
        (new AnswerInlineQuery())
47
            ->setInlineQueryId($queryId)
48
            ->setResults($queryResultArray->getEncodedEntities())
49
            ->trigger();
50
    }
51
52 View Code Duplication
    protected function testVideo()
0 ignored issues
show
Duplication introduced by
This method 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...
53
    {
54
        $queryId = $this->entity->getId();
55
56
        $resultVideo = (new InlineQueryResultVideo())
57
            ->setVideoUrl('https://www.youtube.com/embed/R3my_mHRoto')
58
            ->setMimeTypeHTML()
59
            ->setTitle('Chick with tits')
60
            ->setMessageText('Chick with tits!')
61
            ->setThumbUrl('https://img-fotki.yandex.ru/get/6506/25232117.5/0_6c424_14b6ee9d_S.jpg')
62
            ->setId(1);
63
64
        $queryResultArray = (new InlineQueryResultArray())
65
            ->addEntity($resultVideo);
66
67
68
        (new AnswerInlineQuery())
69
            ->setInlineQueryId($queryId)
70
            ->setResults($queryResultArray->getEncodedEntities())
71
            ->trigger();
72
    }
73
74
    protected function testArticleAndPhoto()
75
    {
76
        $queryId = $this->entity->getId();
77
78
        $resultArticle = (new InlineQueryResultArticle())
79
            ->setTitle('Hello article!')
80
            ->setMessageText('This is an article!')
81
            ->setId(1);
82
83
        $picture = (new InlineQueryResultPhoto())
84
            ->setPhotoUrl('https://img-fotki.yandex.ru/get/6506/25232117.5/0_6c424_14b6ee9d_M.jpg')
85
            ->setThumbUrl('https://img-fotki.yandex.ru/get/6506/25232117.5/0_6c424_14b6ee9d_S.jpg')
86
            ->setPhotoHeight(100)
87
            ->setPhotoWidth(200)
88
            ->setId(2);        
89
90
        $queryResultArray = (new InlineQueryResultArray())
91
            ->addEntity($resultArticle)
92
            ->addEntity($picture);
93
94
95
        (new AnswerInlineQuery())
96
            ->setInlineQueryId($queryId)
97
            ->setResults($queryResultArray->getEncodedEntities())
98
            ->trigger();
99
    }
100
101
    protected function testPhoto() {
102
        $queryId = $this->entity->getId();
103
104
        $pics = [
105
            [
106
                'i' => 'https://img-fotki.yandex.ru/get/6506/25232117.5/0_6c424_14b6ee9d_M.jpg',
107
                't' => 'https://img-fotki.yandex.ru/get/6506/25232117.5/0_6c424_14b6ee9d_S.jpg'
108
            ],
109
            [
110
                'i' => 'https://img-fotki.yandex.ru/get/6504/25232117.5/0_6c420_286b4fd6_M.jpg',
111
                't' => 'https://img-fotki.yandex.ru/get/6504/25232117.5/0_6c420_286b4fd6_S.jpg'
112
            ],
113
            [
114
                'i' => 'https://img-fotki.yandex.ru/get/6509/25232117.5/0_6c41e_ba7c6389_M.jpg',
115
                't' => 'https://img-fotki.yandex.ru/get/6509/25232117.5/0_6c41e_ba7c6389_S.jpg'
116
            ]
117
        ];
118
119
        $queryResultArray = new InlineQueryResultArray();
120
121
        $i = 0;
122
        foreach ($pics as $pic) {
123
            $i++;
124
            $picture = (new InlineQueryResultPhoto())
125
                ->setId($i)
126
                ->setPhotoUrl($pic['i'])
127
                ->setThumbUrl($pic['t'])
128
                ->setPhotoHeight(100)
129
                ->setPhotoWidth(200);
130
131
            $queryResultArray->addEntity($picture);
132
        }
133
134
        (new AnswerInlineQuery())
135
            ->setInlineQueryId($queryId)
136
            ->setResults($queryResultArray->getEncodedEntities())
137
            ->trigger();
138
    }
139
140
    protected function testGifs()
141
    {
142
        $queryId = $this->entity->getId();
143
144
        $gifs = ['http://vignette2.wikia.nocookie.net/halofanon/images/6/66/Mudkip_Dancing_small.gif'];
145
146
        $queryResultArray = new InlineQueryResultArray();
147
        $i = 0;
148
        foreach ($gifs as $gif) {
149
            $i++;
150
            $gifResult = (new InlineQueryResultGif())
151
                ->setId($i)
152
                ->setGifUrl($gif)
153
                ->setGifWidth(100)
154
                ->setGifHeight(100)
155
                ->setThumbUrl($gif);
156
157
            $queryResultArray->addEntity($gifResult);
158
159
            $i++;
160
            $gifResult = (new InlineQueryResultGif())
161
                ->setId($i)
162
                ->setGifUrl($gif)
163
                ->setGifWidth(100)
164
                ->setGifHeight(100)
165
                ->setThumbUrl($gif);
166
167
            $queryResultArray->addEntity($gifResult);
168
169
            $i++;
170
            $gifResult = (new InlineQueryResultGif())
171
                ->setId($i)
172
                ->setGifUrl($gif)
173
                ->setGifWidth(100)
174
                ->setGifHeight(100)
175
                ->setThumbUrl($gif);
176
177
            $queryResultArray->addEntity($gifResult);
178
        }
179
180
        (new AnswerInlineQuery())
181
            ->setInlineQueryId($queryId)
182
            ->setResults($queryResultArray->getEncodedEntities())
183
            ->trigger();
184
    }
185
}
186