Completed
Push — develop ( 41c776...122f3f )
by Josef
02:03
created

Chat::getEmoticons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace ritero\SDK\TwitchTV\Methods;
4
5
use ritero\SDK\TwitchTV\TwitchRequest;
6
use ritero\SDK\TwitchTV\TwitchException;
7
8
/**
9
 * TwitchTV API SDK for PHP
10
 *
11
 * Chat method class
12
 *
13
 * @author Josef Ohnheiser <[email protected]>
14
 * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT
15
 * @homepage https://github.com/jofner/Twitch-SDK
16
 */
17 View Code Duplication
class Chat
1 ignored issue
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...
18
{
19
    /** @var TwitchRequest */
20
    protected $request;
21
22
    const URI_CHAT = 'chat/';
23
    const URI_CHAT_EMOTICONS = 'chat/emoticons';
24
    const URI_CHAT_EMOTICONS_IMAGES = 'chat/emoticon_images';
25
    const URI_CHAT_BADGES = 'chat/%s/badges';
26
27
    /**
28
     * Chat constructor
29
     * @param TwitchRequest $request
30
     */
31
    public function __construct(TwitchRequest $request)
32
    {
33
        $this->request = $request;
34
    }
35
36
    /**
37
     * Returns a links object to all other chat endpoints
38
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatchannel
39
     * @param string $channel
40
     * @return \stdClass
41
     * @throws TwitchException
42
     */
43
    public function getChat($channel)
44
    {
45
        $this->request->setApiVersion(3);
46
47
        return $this->request->request(self::URI_CHAT . $channel);
48
    }
49
50
    /**
51
     * Get a chat's emoticons
52
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatemoticons
53
     * @return \stdClass
54
     * @throws TwitchException
55
     */
56
    public function getEmoticons()
57
    {
58
        $this->request->setApiVersion(3);
59
60
        return $this->request->request(self::URI_CHAT_EMOTICONS);
61
    }
62
63
    /**
64
     * Returns a list of emoticons
65
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatemoticon_images
66
     * @param string $queryString
67
     * @return \stdClass
68
     * @throws TwitchException
69
     */
70
    public function getEmoticonImages($queryString)
71
    {
72
        $this->request->setApiVersion(3);
73
74
        return $this->request->request(self::URI_CHAT_EMOTICONS_IMAGES . $queryString);
75
    }
76
77
    /**
78
     * Returns a list of chat badges that can be used in the :channel's chat
79
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatchannelbadges
80
     * @param string $channel
81
     * @return \stdClass
82
     * @throws TwitchException
83
     */
84
    public function getBadges($channel)
85
    {
86
        $this->request->setApiVersion(3);
87
88
        return $this->request->request(sprintf(self::URI_CHAT_BADGES, $channel));
89
    }
90
}
91