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::__construct()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 11
cts 11
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
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