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.

JOSE::isJWS()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
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 51
    public function __construct(Header ...$headers)
24
    {
25 51
        $params = [];
26 51
        foreach ($headers as $header) {
27 51
            foreach ($header->parameters() as $param) {
28 51
                if (isset($params[$param->name()])) {
29 1
                    throw new \UnexpectedValueException('Duplicate parameter.');
30
                }
31 51
                $params[$param->name()] = $param;
32
            }
33
        }
34 50
        parent::__construct(...array_values($params));
35 50
    }
36
37
    /**
38
     * Get self merged with another Header.
39
     */
40 2
    public function withHeader(Header $header): self
41
    {
42 2
        return new self($this, $header);
43
    }
44
45
    /**
46
     * Whether JOSE is for a JWS.
47
     */
48 2
    public function isJWS(): bool
49
    {
50 2
        return $this->hasAlgorithm() && !$this->hasEncryptionAlgorithm();
51
    }
52
53
    /**
54
     * Whether JOSE is for a JWE.
55
     */
56 2
    public function isJWE(): bool
57
    {
58 2
        return $this->hasEncryptionAlgorithm();
59
    }
60
}
61