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.

JoseBuilder::jwkSetUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Gandung\JWT\Token;
4
5
use Gandung\JWT\Exception\AlgorithmHeaderValueMismatchException;
6
use Gandung\JWT\Exception\JoseTokenMismatchException;
7
use Gandung\JWT\TokenValidator\AlgorithmHeaderValue;
8
use Gandung\JWT\TokenValidator\JoseHeader;
9
use Psr\Http\Message\UriInterface;
10
11
/**
12
 * @author Paulus Gandung Prakosa <[email protected]>
13
 */
14
class JoseBuilder implements JoseBuilderInterface
15
{
16
    /**
17
     * @var array
18
     */
19
    private $jose = [];
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function algorithm($algo)
25
    {
26
        if (!AlgorithmHeaderValue::create()->validate($algo)) {
27
            throw new AlgorithmHeaderValueMismatchException("Supply valid algorithm header value.");
28
        }
29
30
        return $this->collectJose(Jose::ALGORITHM, $algo);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function jwkSetUrl(UriInterface $url)
37
    {
38
        return $this->collectJose(Jose::JWK_SET_URL, (string)$url);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function keyID($id)
45
    {
46
        return $this->collectJose(Jose::KEY_ID, $id);
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function x509Url(UriInterface $url)
53
    {
54
        return $this->collectJose(Jose::X509_URL, (string)$url);
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function type($type)
61
    {
62
        return $this->collectJose(Jose::TYPE, $type);
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function contentType($type)
69
    {
70
        return $this->collectJose(Jose::CONTENT_TYPE, $type);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function getValue()
77
    {
78
        return $this->jose;
79
    }
80
    
81
    /**
82
     * Aggregate JOSE header by pairing it's name with it's value.
83
     *
84
     * @param string $name
85
     * @param mixed $value
86
     * @return $this
87
     */
88
    private function collectJose($name, $value)
89
    {
90
        if (!JoseHeader::create()->validate($name)) {
91
            throw new JoseTokenMismatchException("Supply valid JOSE header name.");
92
        }
93
        
94
        $this->jose[$name] = $value;
95
96
        return $this;
97
    }
98
}
99