Passed
Push — master ( 2afdeb...b846a2 )
by Nikolaos
06:23 queued 03:51
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 2
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
 * 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