Passed
Push — master ( 85c6cc...2afdeb )
by Nikolaos
04:50 queued 10s
created

Token   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 88.24%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 81
ccs 15
cts 17
cp 0.8824
rs 10
c 1
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getClaims() 0 3 1
A getPayload() 0 3 1
A getToken() 0 3 1
A getSignature() 0 3 1
A getHeaders() 0 3 1
A signature() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the Phalcon Framework.
5
 *
6
 * For the full copyright and license information, please view the LICENSE.md
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Phalcon\Http\JWT\Token;
13
14
/**
15
 * Class Token
16
 *
17
 * @property Item      $claims
18
 * @property Item      $jose
19
 * @property Signature $signature
20
 *
21
 * @link https://tools.ietf.org/html/rfc7519
22
 */
23
class Token
24
{
25
    /**
26
     * @var Item
27
     */
28
    private $claims;
29
30
    /**
31
     * @var Item
32
     */
33
    private $jose;
34
35
    /**
36
     * @var Signature
37
     */
38
    private $signature;
39
40
    /**
41
     * Token constructor.
42
     *
43
     * @param Item      $jose
44
     * @param Item      $claims
45
     * @param Signature $signature
46
     */
47 31
    public function __construct(
48
        Item $jose,
49
        Item $claims,
50
        Signature $signature
51
    ) {
52 31
        $this->jose      = $jose;
53 31
        $this->claims    = $claims;
54 31
        $this->signature = $signature;
55 31
    }
56
57
    /**
58
     * @return Item
59
     */
60 12
    public function getClaims(): Item
61
    {
62 12
        return $this->claims;
63
    }
64
65
    /**
66
     * @return Item
67
     */
68 4
    public function getHeaders(): Item
69
    {
70 4
        return $this->jose;
71
    }
72
73
    /**
74
     * @return string
75
     */
76 7
    public function getPayload(): string
77
    {
78 7
        return $this->jose->getEncoded() . "." . $this->claims->getEncoded();
79
    }
80
81
    /**
82
     * @return Signature
83
     */
84 8
    public function getSignature(): Signature
85
    {
86 8
        return $this->signature;
87
    }
88
89
    /**
90
     * @return string
91
     */
92 4
    public function getToken(): string
93
    {
94 4
        return $this->getPayload() . "." . $this->getSignature()->getEncoded();
95
    }
96
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    public function signature(): Signature
102
    {
103
        return $this->signature;
104
    }
105
}
106