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.

Jws::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Emarref\Jwt\Signature;
4
5
use Emarref\Jwt\Encoding\EncoderInterface;
6
use Emarref\Jwt\Encryption\EncryptionInterface;
7
use Emarref\Jwt\HeaderParameter\Algorithm;
8
use Emarref\Jwt\Token;
9
10
class Jws implements SignerInterface
11
{
12
    /**
13
     * @var EncryptionInterface
14
     */
15
    private $encryption;
16
17
    /**
18
     * @var EncoderInterface
19
     */
20
    private $encoder;
21
22
    public function __construct(EncryptionInterface $encryption, EncoderInterface $encoder)
23
    {
24
        $this->encryption = $encryption;
25
        $this->encoder    = $encoder;
26
    }
27
28 View Code Duplication
    public function getUnsignedValue(Token $token)
29
    {
30
        $jsonHeader    = $token->getHeader()->getParameters()->jsonSerialize();
31
        $encodedHeader = $this->encoder->encode($jsonHeader);
32
33
        $jsonPayload    = $token->getPayload()->getClaims()->jsonSerialize();
34
        $encodedPayload = $this->encoder->encode($jsonPayload);
35
36
        return sprintf('%s.%s', $encodedHeader, $encodedPayload);
37
    }
38
39
    public function sign(Token $token)
40
    {
41
        $token->addHeader(new Algorithm($this->encryption->getAlgorithmName()));
42
43
        $rawSignature = $this->getUnsignedValue($token);
44
45
        $signature = $this->encryption->encrypt($rawSignature);
46
47
        $token->setSignature($signature);
48
    }
49
}
50