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.

Rs512Test   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 40
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 5 5 1
A testGetName() 4 4 1
A testGetAlgorithm() 4 4 1
A testCompute() 8 8 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 Emarref\Jwt\Algorithm;
4
5 View Code Duplication
class Rs512Test extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
    private static $name          = 'RS512';
8
    private static $algorithmName = 'sha512';
9
10
    /**
11
     * @var string
12
     */
13
    private $key;
14
15
    /**
16
     * @var Rs512
17
     */
18
    private $algorithm;
19
20
    public function setUp()
21
    {
22
        $this->key = openssl_pkey_new();
0 ignored issues
show
Documentation Bug introduced by
It seems like openssl_pkey_new() of type resource is incompatible with the declared type string of property $key.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23
        $this->algorithm = new Rs512();
24
    }
25
26
    public function testGetName()
27
    {
28
        $this->assertSame(self::$name, $this->algorithm->getName());
29
    }
30
31
    public function testGetAlgorithm()
32
    {
33
        $this->assertSame(self::$algorithmName, $this->algorithm->getAlgorithm());
34
    }
35
36
    public function testCompute()
37
    {
38
        $unencryptedValue = 'foobar';
39
        openssl_sign($unencryptedValue, $encryptedValue, $this->key, OPENSSL_ALGO_SHA512);
40
        $signature = $this->algorithm->sign($unencryptedValue, $this->key);
41
42
        $this->assertSame($encryptedValue, $signature);
43
    }
44
}
45