Chat   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 16
c 2
b 1
f 1
lcom 1
cbo 7
dl 0
loc 93
ccs 0
cts 61
cp 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getChannelLinks() 0 14 3
A getEmoticons() 0 6 1
A getChannelEmoticons() 0 12 3
A getChannelBadges() 0 19 3
A getEmoticonImages() 0 12 3
A getEmoticonSets() 0 12 3
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
}