Stream   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 67
loc 67
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getStream() 4 4 1
A getStreams() 4 4 1
A getFeatured() 4 4 1
A getSummary() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace jofner\SDK\TwitchTV\Methods;
4
5
use jofner\SDK\TwitchTV\TwitchRequest;
6
use jofner\SDK\TwitchTV\TwitchSDKException;
7
8
/**
9
 * Streams method class for TwitchTV API SDK for PHP
10
 *
11
 * @author Josef Ohnheiser <[email protected]>
12
 * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT
13
 * @homepage https://github.com/jofner/Twitch-SDK
14
 */
15 View Code Duplication
class Stream
16
{
17
    /** @var TwitchRequest */
18
    protected $request;
19
20
    const URI_STREAM = 'streams/';
21
    const URI_STREAMS = 'streams';
22
    const URI_STREAMS_FEATURED = 'streams/featured';
23
    const URI_STREAM_SUMMARY = 'streams/summary';
24
25
    /**
26
     * Stream constructor
27
     * @param TwitchRequest $request
28
     */
29
    public function __construct(TwitchRequest $request)
30
    {
31
        $this->request = $request;
32
    }
33
34
    /**
35
     * Get the specified channel's stream
36
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamschannel
37
     * @param string $channel
38
     * @return \stdClass
39
     * @throws TwitchSDKException
40
     */
41
    public function getStream($channel)
42
    {
43
        return $this->request->request(self::URI_STREAM . $channel);
44
    }
45
46
    /**
47
     * Returns a list of streams
48
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streams
49
     * @param string $queryString
50
     * @return \stdClass
51
     * @throws TwitchSDKException
52
     */
53
    public function getStreams($queryString)
54
    {
55
        return $this->request->request(self::URI_STREAMS . $queryString);
56
    }
57
58
    /**
59
     * Returns a list of featured (promoted) stream
60
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamsfeatured
61
     * @param string $queryString
62
     * @return \stdClass
63
     * @throws TwitchSDKException
64
     */
65
    public function getFeatured($queryString)
66
    {
67
        return $this->request->request(self::URI_STREAMS_FEATURED . $queryString);
68
    }
69
70
    /**
71
     * Returns a summary of current streams
72
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamssummary
73
     * @param string $queryString
74
     * @return \stdClass
75
     * @throws TwitchSDKException
76
     */
77
    public function getSummary($queryString)
78
    {
79
        return $this->request->request(self::URI_STREAM_SUMMARY . $queryString);
80
    }
81
}
82