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 ( ce507f...5e3b1d )
by Joni
04:09
created

Base64URLValue   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 47
wmc 4
lcom 0
cbo 2
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
value() 0 1 ?
A fromString() 0 3 1
A _validateEncoding() 0 7 2
A string() 0 3 1
1
<?php
2
3
namespace JWX\Parameter\Feature;
4
5
use JWX\Util\Base64;
6
7
8
/**
9
 * Trait for parameters having Base64url value.
10
 */
11
trait Base64URLValue
12
{
13
	use StringParameterValue;
14
	
15
	/**
16
	 * Get the parameter value.
17
	 *
18
	 * @return string
19
	 */
20
	abstract public function value();
21
	
22
	/**
23
	 * Initialize from native value.
24
	 *
25
	 * Value shall be encoded using Base64url encoding.
26
	 *
27
	 * @param string $value
28
	 * @return self
29
	 */
30 86
	public static function fromString($value) {
31 86
		return new static(Base64::urlEncode($value));
32
	}
33
	
34
	/**
35
	 * Validate that value is validly base64url encoded.
36
	 *
37
	 * @param string $value
38
	 * @throws \UnexpectedValueException
39
	 * @return self
40
	 */
41 124
	protected function _validateEncoding($value) {
42 124
		if (!Base64::isValidURLEncoding($value)) {
43 1
			throw new \UnexpectedValueException(
44 1
				"Value must be base64url encoded.");
45
		}
46 123
		return $this;
47
	}
48
	
49
	/**
50
	 * Get the parameter value as a decoded string.
51
	 *
52
	 * @return string
53
	 */
54 32
	public function string() {
55 32
		return Base64::urlDecode($this->value());
56
	}
57
}
58