Completed
Push — master ( c1abc1...1c17fb )
by Josef
03:52
created

Auth   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getLoginURL() 4 4 1
A getAccessToken() 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\TwitchSDKException;
6
use jofner\SDK\TwitchTV\TwitchRequest;
7
8
/**
9
 * Authenticate 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
16 View Code Duplication
class Auth
17
{
18
    /** @var TwitchRequest */
19
    protected $request;
20
21
    const URI_AUTH = 'oauth2/authorize';
22
    const URI_AUTH_TOKEN = 'oauth2/token';
23
24
    public function __construct(TwitchRequest $request)
25
    {
26
        $this->request = $request;
27
    }
28
29
    /**
30
     * Get login URL for authentication
31
     * @param string $queryString
32
     * @return string
33
     * @throws TwitchSDKException
34
     */
35
    public function getLoginURL($queryString)
36
    {
37
        return $this->request->request(self::URI_AUTH . $queryString);
38
    }
39
40
    /**
41
     * Get authentication access token
42
     * @param string $queryString
43
     * @return \stdClass
44
     * @throws TwitchSDKException
45
     */
46
    public function getAccessToken($queryString)
47
    {
48
        return $this->request->request(self::URI_AUTH_TOKEN, 'POST', $queryString);
49
    }
50
}
51