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   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
eloc 11
dl 0
loc 51
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 4
A withHeader() 0 3 1
A isJWS() 0 3 2
A isJWE() 0 3 1
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