GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ClaimBuilderTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A callCollectClaimDirectly() 0 7 1
A testCanGetInstance() 0 4 1
A testCanBuildJWTClaimAndGetItAfterwards() 0 14 1
A testCanRaiseExceptionWhileStoreValueInWrongClaimName() 0 4 1
1
<?php
2
3
namespace Gandung\JWT\Tests\Token;
4
5
use PHPUnit\Framework\TestCase;
6
use Gandung\JWT\Token\ClaimBuilder;
7
8
/**
9
 * @author Paulus Gandung Prakosa <[email protected]>
10
 */
11
class ClaimBuilderTest extends TestCase
12
{
13
    private function callCollectClaimDirectly($name, $value)
14
    {
15
        $refl = new \ReflectionClass(ClaimBuilder::class);
16
        $collector = $refl->getMethod('collectClaim');
17
        $collector->setAccessible(true);
18
        $instance = $collector->invokeArgs($refl->newInstanceWithoutConstructor(), [$name, $value]);
0 ignored issues
show
Unused Code introduced by
$instance is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
19
    }
20
21
    public function testCanGetInstance()
22
    {
23
        $this->assertInstanceOf(ClaimBuilder::class, new ClaimBuilder);
24
    }
25
26
    public function testCanBuildJWTClaimAndGetItAfterwards()
27
    {
28
        $builder = (new ClaimBuilder)
29
            ->issuedBy('Paulus Gandung Prakosa')
30
            ->relatedTo('something')
31
            ->intendedFor('everybody')
32
            ->expireAt(new \DateTimeImmutable('@' . (time() + (3600 * 3))))
33
            ->canOnlyBeUsedAfter(new \DateTimeImmutable('@' . (time() - (3600 * 3))))
34
            ->issuedAt(new \DateTimeImmutable('@' . (time() - (3600 * 24))))
35
            ->identifiedBy(md5(uniqid()));
36
        $aggregated = $builder->getValue();
37
        $this->assertInternalType('array', $aggregated);
38
        $this->assertNotEmpty($aggregated);
39
    }
40
41
    /**
42
     * @expectedException \Gandung\JWT\Exception\ClaimTokenMismatchException
43
     */
44
    public function testCanRaiseExceptionWhileStoreValueInWrongClaimName()
45
    {
46
        $this->callCollectClaimDirectly('shit', 'this_is_truly_a_shit');
47
    }
48
}
49