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.
Passed
Branch php72 (880eb0)
by Joni
05:58
created

JOSE::__construct()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 1
crap 4
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\JWX\JWT\Header;
6
7
/**
8
 * Represents as JOSE header.
9
 *
10
 * JOSE header consists of one or more Header objects, that are merged together.
11
 *
12
 * @see https://tools.ietf.org/html/rfc7519#section-5
13
 * @see https://tools.ietf.org/html/rfc7515#section-4
14
 * @see https://tools.ietf.org/html/rfc7516#section-4
15
 */
16
class JOSE extends Header
17
{
18
    /**
19
     * Constructor.
20
     *
21
     * @param Header ...$headers One or more headers to merge
22
     */
23 50
    public function __construct(Header ...$headers)
24
    {
25 50
        $params = [];
26 50
        foreach ($headers as $header) {
27 50
            foreach ($header->parameters() as $param) {
28 50
                if (isset($params[$param->name()])) {
29 1
                    throw new \UnexpectedValueException('Duplicate parameter.');
30
                }
31 50
                $params[$param->name()] = $param;
32
            }
33
        }
34 49
        parent::__construct(...array_values($params));
35 49
    }
36
37
    /**
38
     * Get self merged with another Header.
39
     *
40
     * @param Header $header
41
     *
42
     * @return self
43
     */
44 2
    public function withHeader(Header $header): self
45
    {
46 2
        return new self($this, $header);
47
    }
48
49
    /**
50
     * Whether JOSE is for a JWS.
51
     *
52
     * @return bool
53
     */
54 2
    public function isJWS(): bool
55
    {
56 2
        return $this->hasAlgorithm() && !$this->hasEncryptionAlgorithm();
57
    }
58
59
    /**
60
     * Whether JOSE is for a JWE.
61
     *
62
     * @return bool
63
     */
64 2
    public function isJWE(): bool
65
    {
66 2
        return $this->hasEncryptionAlgorithm();
67
    }
68
}
69