Completed
Push — master ( c14ed6...643334 )
by Johnny
02:41
created

Chat   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 0%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getChannelLinks() 0 14 3
A getEmoticons() 0 5 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())
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34
        // TODO Not done
35
        throw new Exception\RuntimeException('Not implemented do to 504 on twitch API.');
36
    }
37
38
    public function getChannelEmoticons($args = array())
39
    {
40
        $response = $this->call('getChannelEmoticons', $args);
41
42
        $channel_emoticons = new Twitch\ChatChannelEmoticons;
43
44
        if (is_object($response) === true && isset($response->emoticons) === true) {
45
            $channel_emoticons->setEmoticons($response->emoticons);
46
            return $channel_emoticons;
47
        }
48
        return false;
49
    }
50
51
    public function getChannelBadges($args = array())
52
    {
53
        $response = $this->call('getChannelBadges', $args);
54
55
        $channel_badges = new Twitch\ChatChannelBadges;
56
57
        if (is_object($response) === true && isset($response->broadcaster) === true) {
58
59
            $channel_badges->setAdmin($response->admin);
60
            $channel_badges->setBroadcaster($response->broadcaster);
61
            $channel_badges->setSubscriber($response->subscriber);
62
            $channel_badges->setGlobalMod($response->global_mod);
63
            $channel_badges->setStaff($response->staff);
64
            $channel_badges->setTurbo($response->turbo);
65
            $channel_badges->setMod($response->mod);
66
            return $channel_badges;
67
        }
68
        return false;
69
    }
70
71
    public function getEmoticonImages($args = array())
72
    {
73
        $response = $this->call('getEmoticonImages', $args);
74
75
        $emoticon_images = new Twitch\ChatEmoticonImages;
76
77
        if (is_object($response) === true && isset($response->emoticons) === true) {
78
            $emoticon_images->setEmoticons($response->emoticons);
79
        }
80
81
        return $emoticon_images;
82
    }
83
84
    public function getEmoticonSets($args = array())
85
    {
86
        $response = $this->call('getEmoticonSets', $args);
87
88
        $emoticon_sets = new Twitch\ChatEmoticonImageSets;
89
    print_r($emoticon_sets);
90
        if (is_object($response) === true && isset($response->emoticon_sets) === true) {
91
            $emoticon_sets->setEmoticonSets($response->emoticon_sets);
92
        }
93
94
        return $emoticon_sets;
95
    }
96
97
}