Chat::getEmoticonSets()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
ccs 0
cts 9
cp 0
rs 9.4286
cc 3
eloc 6
nc 2
nop 1
crap 12
1
<?php
2
namespace Redbox\Twitch\Resource;
3
use Redbox\Twitch\Exception;
4
use Redbox\Twitch;
5
6
class Chat extends ResourceAbstract
7
{
8
9
    public function getChannelLinks($args = array())
10
    {
11
        $response = $this->call('getChannelLinks', $args);
12
13
        if (is_object($response) === true && isset($response->_links) === true) {
14
            $channel_link = new Twitch\ChatChannelLink;
15
            $channel_link->setEmoticons($response->_links->emoticons);
16
            $channel_link->setBadges($response->_links->badges);
17
            $channel_link->setSelf($response->_links->self);
18
19
            return $channel_link;
20
        }
21
        return false;
22
    }
23
24
    /**
25
     * NOTE: /chat/emoticons seems no longer supported a since march 2015 it returns a 504
26
     * see https://github.com/johnnymast/redbox-twitch/issues/4
27
     *
28
     * @deprecated
29
     * @param array $args
30
     * @throws Exception\RuntimeException
31
     */
32
    public function getEmoticons($args = array())
33
    {
34
        // TODO Not done
35
        $args;
36
        throw new Exception\RuntimeException('Not implemented do to 504 on twitch API.');
37
    }
38
39
    public function getChannelEmoticons($args = array())
40
    {
41
        $response = $this->call('getChannelEmoticons', $args);
42
43
        $channel_emoticons = new Twitch\ChatChannelEmoticons;
44
45
        if (is_object($response) === true && isset($response->emoticons) === true) {
46
            $channel_emoticons->setEmoticons($response->emoticons);
47
            return $channel_emoticons;
48
        }
49
        return false;
50
    }
51
52
    public function getChannelBadges($args = array())
53
    {
54
        $response = $this->call('getChannelBadges', $args);
55
56
        $channel_badges = new Twitch\ChatChannelBadges;
57
58
        if (is_object($response) === true && isset($response->broadcaster) === true) {
59
60
            $channel_badges->setAdmin($response->admin);
61
            $channel_badges->setBroadcaster($response->broadcaster);
62
            $channel_badges->setSubscriber($response->subscriber);
63
            $channel_badges->setGlobalMod($response->global_mod);
64
            $channel_badges->setStaff($response->staff);
65
            $channel_badges->setTurbo($response->turbo);
66
            $channel_badges->setMod($response->mod);
67
            return $channel_badges;
68
        }
69
        return false;
70
    }
71
72
    public function getEmoticonImages($args = array())
73
    {
74
        $response = $this->call('getEmoticonImages', $args);
75
76
        $emoticon_images = new Twitch\ChatEmoticonImages;
77
78
        if (is_object($response) === true && isset($response->emoticons) === true) {
79
            $emoticon_images->setEmoticons($response->emoticons);
80
        }
81
82
        return $emoticon_images;
83
    }
84
85
    public function getEmoticonSets($args = array())
86
    {
87
        $response = $this->call('getEmoticonSets', $args);
88
89
        $emoticon_sets = new Twitch\ChatEmoticonImageSets;
90
91
        if (is_object($response) === true && isset($response->emoticon_sets) === true) {
92
            $emoticon_sets->setEmoticonSets($response->emoticon_sets);
93
        }
94
95
        return $emoticon_sets;
96
    }
97
98
}