Team   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 41
loc 41
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getTeam() 4 4 1
A getTeams() 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
 * Teams 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 Team
16
{
17
    /** @var TwitchRequest */
18
    protected $request;
19
20
    const URI_TEAM = 'teams/';
21
    const URI_TEAMS = 'teams';
22
23
    /**
24
     * Team constructor
25
     * @param TwitchRequest $request
26
     */
27
    public function __construct(TwitchRequest $request)
28
    {
29
        $this->request = $request;
30
    }
31
32
    /**
33
     * Get the specified team
34
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md#get-teamsteam
35
     * @param string $team
36
     * @return \stdClass
37
     * @throws TwitchSDKException
38
     */
39
    public function getTeam($team)
40
    {
41
        return $this->request->request(self::URI_TEAM . $team);
42
    }
43
44
    /**
45
     * Returns a list of active teams
46
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md#get-teams
47
     * @param $queryString
48
     * @return \stdClass
49
     * @throws TwitchSDKException
50
     */
51
    public function getTeams($queryString)
52
    {
53
        return $this->request->request(self::URI_TEAMS . $queryString);
54
    }
55
}
56