Completed
Push — develop ( 2b0d56...088525 )
by Josef
02:15
created

Stream   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

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\TwitchException;
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
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...
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 TwitchException
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 TwitchException
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 TwitchException
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 TwitchException
76
     */
77
    public function getSummary($queryString)
78
    {
79
        return $this->request->request(self::URI_STREAM_SUMMARY . $queryString);
80
    }
81
}
82