Completed
Push — master ( a054a0...cffdc3 )
by Johnny
02:13
created

Root::getRoot()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
ccs 0
cts 19
cp 0
rs 8.5907
cc 5
eloc 14
nc 4
nop 1
crap 30
1
<?php
2
namespace Redbox\Twitch\Resource;
3
use Redbox\Twitch;
4
5
class Root extends ResourceAbstract {
6
7
    public function getRoot($args = array())
8
    {
9
        $response = $this->call('get', $args);
10
11
        $root = new Twitch\Root;
12
13
        if (is_object($response) == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
14
            if (isset($response->token) == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
15
16
                $root->setValid($response->token->valid);
17
18
                if ($root->isValid() == true && isset($response->token->authorization) == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
19
                    $root->setUserName($response->token->user_name);
20
                    $authorization = new Twitch\Authorization;
21
                    $authorization->setScopes($response->token->authorization->scopes);
22
                    $authorization->setCreatedAt($response->token->authorization->created_at);
23
                    $authorization->setUpdatedAt($response->token->authorization->created_at);
24
                    $root->setAuthorization($authorization);
25
                }
26
            }
27
        }
28
        return $root;
29
    }
30
}