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.
Completed
Push — master ( 90b318...149c7a )
by Joni
04:00
created

JOSE   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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