JWT   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 66
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A headers() 0 3 1
A payload() 0 3 1
A encoded() 0 3 1
1
<?php
2
3
namespace Parroauth2\Client\Jwt;
4
5
/**
6
 * Store the parsed JWT data
7
 */
8
final class JWT
9
{
10
    /**
11
     * Raw encoded payload of the JWT
12
     *
13
     * @var string
14
     */
15
    private $encoded;
16
17
    /**
18
     * Merged value of protected and unprotected headers
19
     *
20
     * @var array
21
     */
22
    private $headers;
23
24
    /**
25
     * The payload
26
     * Should be array|string for handle wrapped JWT (i.e. JWS into a JWE)
27
     *
28
     * @var array
29
     */
30
    private $payload;
31
32
    /**
33
     * JWT constructor.
34
     *
35
     * @param string $encoded
36
     * @param array $headers
37
     * @param array $payload
38
     */
39 28
    public function __construct(string $encoded, array $headers, array $payload)
40
    {
41 28
        $this->encoded = $encoded;
42 28
        $this->headers = $headers;
43 28
        $this->payload = $payload;
44 28
    }
45
46
    /**
47
     * Get the raw encoded value of the JWT
48
     *
49
     * @return string
50
     */
51 2
    public function encoded(): string
52
    {
53 2
        return $this->encoded;
54
    }
55
56
    /**
57
     * Merged value of protected and unprotected headers
58
     *
59
     * @return array
60
     */
61 19
    public function headers(): array
62
    {
63 19
        return $this->headers;
64
    }
65
66
    /**
67
     * The JWT payload
68
     *
69
     * @return array
70
     */
71 27
    public function payload(): array
72
    {
73 27
        return $this->payload;
74
    }
75
}
76