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.

Base64URLValue   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 45
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

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