Completed
Push — master ( 854a6f...c7bd33 )
by Chad
12s
created

Token::getTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Chadicus\Psr\Http\ServerMiddleware;
4
5
/**
6
 * Immutable hmac authentication token.
7
 */
8
final class Token
9
{
10
    /**
11
     * The public api key.
12
     *
13
     * @var string
14
     */
15
    private $publicKey;
16
17
    /**
18
     * A unique hash for the request.
19
     *
20
     * @var string
21
     */
22
    private $signature;
23
24
    /**
25
     * An arbitrary string used only once.
26
     *
27
     * @var string
28
     */
29
    private $nonce;
30
31
    /**
32
     * The request timestamp.
33
     *
34
     * @var integer
35
     */
36
    private $timestamp;
37
38
    /**
39
     * Construct a new Token instance
40
     *
41
     * @param string  $publicKey The public api key.
42
     * @param string  $signature A unique hash for the request.
43
     * @param string  $nonce     An arbitrary string used only once.
44
     * @param integer $timestamp The request timestamp.
45
     *
46
     * @throws \InvalidArgumentException Thrown if any parameters are invalid.
47
     */
48
    public function __construct(string $publicKey, string $signature, string $nonce, int $timestamp)
49
    {
50
        $this->publicKey = $publicKey;
51
        $this->signature = $signature;
52
        $this->nonce = $nonce;
53
        $this->timestamp = $timestamp;
54
    }
55
56
    /**
57
     * The public api key found in the request.
58
     *
59
     * @return string
60
     */
61
    public function getPublicKey() : string
62
    {
63
        return $this->publicKey;
64
    }
65
66
    /**
67
     * Returns the signature of the request.
68
     *
69
     * @return string
70
     */
71
    public function getSignature() : string
72
    {
73
        return $this->signature;
74
    }
75
76
    /**
77
     * Returns the nonce value found in the request.
78
     *
79
     * @return string
80
     */
81
    public function getNonce() : string
82
    {
83
        return $this->nonce;
84
    }
85
86
    /**
87
     * Returns the timestamp of the request.
88
     *
89
     * @return integer
90
     */
91
    public function getTimestamp() : int
92
    {
93
        return $this->timestamp;
94
    }
95
}
96