AuthModel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 31
ccs 0
cts 20
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createAuthUrl() 0 18 3
1
<?php
2
namespace Redbox\Twitch\Auth;
3
use Redbox\Twitch\Client;
4
5
class AuthModel
6
{
7
    /**
8
     * @var Client
9
     */
10
    protected $client;
11
12
    public function __construct(Client $client)
13
    {
14
        $this->client = $client;
15
    }
16
17
    public function createAuthUrl($scopes = '', $state = null) {
18
        $addy = '';
19
        if ($this->client->isForceRelogin() === true) {
20
            $addy .= '&force_verify=true';
21
        }
22
23
        if ($state)
24
            $addy .= '&state='.$state;
25
26
        $url =  sprintf('%s/oauth2/authorize/?response_type=code&client_id=%s&redirect_uri=%s&scope=%s%s',
27
            $this->client->getApiUrl(),
28
            $this->client->getClientId(),
29
            $this->client->getRedirectUri(),
30
            urlencode($scopes),
31
            $addy
32
        );
33
        return $url;
34
    }
35
}