Passed
Push — master ( 9e9627...c94b6d )
by Nikolaos
02:17
created

Token::signature()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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