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.

PayloadTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 19.3 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testSetClaim() 0 10 1
A testFindClaimByName() 11 11 1
A testGetClaims() 0 4 1
A testJsonSerialize() 0 10 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\Token;
4
5
use Emarref\Jwt\Claim;
6
7
class PayloadTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @var \PHPUnit_Framework_MockObject_MockObject
11
     */
12
    private $claims;
13
14
    /**
15
     * @var PayloadStub
16
     */
17
    private $payload;
18
19
    public function setUp()
20
    {
21
        $this->claims  = $this->getMockBuilder('Emarref\Jwt\Token\PropertyList')->getMock();
22
        $this->payload = new PayloadStub($this->claims);
23
    }
24
25
    public function testSetClaim()
26
    {
27
        $claim = new Claim\PrivateClaim('name', 'value');
28
29
        $this->claims->expects($this->once())
30
            ->method('setProperty')
31
            ->with($claim);
32
33
        $this->payload->setClaim($claim);
34
    }
35
36 View Code Duplication
    public function testFindClaimByName()
37
    {
38
        $claim = new Claim\PrivateClaim('name', 'value');
39
40
        $this->claims->expects($this->exactly(2))
41
            ->method('getIterator')
42
            ->will($this->returnValue(new \ArrayObject([$claim])));
43
44
        $this->assertSame($claim, $this->payload->findClaimByName('name'));
45
        $this->assertNull($this->payload->findClaimByName('none'));
46
    }
47
48
    public function testGetClaims()
49
    {
50
        $this->assertSame($this->claims, $this->payload->getClaims());
51
    }
52
53
    public function testJsonSerialize()
54
    {
55
        $expectedJson = '{"whatever":true}';
56
57
        $this->claims->expects($this->once())
58
            ->method('jsonSerialize')
59
            ->will($this->returnValue($expectedJson));
60
61
        $this->assertSame($expectedJson, $this->payload->jsonSerialize());
62
    }
63
}
64