|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Stefano Torresi (http://stefanotorresi.it) |
|
4
|
|
|
* @license See the file LICENSE.txt for copying permission. |
|
5
|
|
|
* ************************************************ |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Thorr\Nonce\Entity; |
|
9
|
|
|
|
|
10
|
|
|
use DateTime; |
|
11
|
|
|
use Ramsey\Uuid\Uuid; |
|
12
|
|
|
use Thorr\Persistence\Entity\AbstractEntity; |
|
13
|
|
|
|
|
14
|
|
|
class Nonce extends AbstractEntity |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Null value means nonce doesn't expire, ever |
|
18
|
|
|
* |
|
19
|
|
|
* @var DateTime |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $expirationDate; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var NonceOwnerInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $owner; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $namespace; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
* |
|
36
|
|
|
* @param DateTime $expirationDate |
|
37
|
|
|
* @param string $namespace |
|
38
|
|
|
*/ |
|
39
|
8 |
|
public function __construct(Uuid $uuid = null, DateTime $expirationDate = null, $namespace = null) |
|
40
|
|
|
{ |
|
41
|
8 |
|
parent::__construct($uuid); |
|
42
|
|
|
|
|
43
|
8 |
|
$this->setExpirationDate($expirationDate); |
|
44
|
8 |
|
$this->setNamespace($namespace); |
|
45
|
8 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param DateTime|null $expirationDate |
|
49
|
|
|
*/ |
|
50
|
8 |
|
public function setExpirationDate(DateTime $expirationDate = null) |
|
51
|
|
|
{ |
|
52
|
8 |
|
$this->expirationDate = $expirationDate; |
|
53
|
8 |
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return DateTime|null |
|
57
|
|
|
*/ |
|
58
|
9 |
|
public function getExpirationDate() |
|
59
|
|
|
{ |
|
60
|
9 |
|
return $this->expirationDate; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param NonceOwnerInterface $owner |
|
65
|
|
|
*/ |
|
66
|
4 |
|
public function setOwner(NonceOwnerInterface $owner) |
|
67
|
|
|
{ |
|
68
|
4 |
|
$this->owner = $owner; |
|
69
|
4 |
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return NonceOwnerInterface |
|
73
|
|
|
*/ |
|
74
|
1 |
|
public function getOwner() |
|
75
|
|
|
{ |
|
76
|
1 |
|
return $this->owner; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return string |
|
81
|
|
|
*/ |
|
82
|
1 |
|
public function getNamespace() |
|
83
|
|
|
{ |
|
84
|
1 |
|
return $this->namespace; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param string $namespace |
|
89
|
|
|
*/ |
|
90
|
8 |
|
public function setNamespace($namespace) |
|
91
|
|
|
{ |
|
92
|
8 |
|
$this->namespace = $namespace; |
|
93
|
8 |
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|