1 | <?php |
||
5 | abstract class NoncerAbstract implements NoncerInterface |
||
6 | { |
||
7 | const DEFAULT_LENGTH = 24; |
||
8 | |||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $lastNonce = ''; |
||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | protected $length; |
||
18 | |||
19 | /** |
||
20 | * @param integer $length |
||
21 | */ |
||
22 | 63 | public function __construct($length = self::DEFAULT_LENGTH) |
|
26 | |||
27 | /** |
||
28 | * @param int $length |
||
29 | */ |
||
30 | 30 | public function setLength($length) |
|
34 | |||
35 | /** |
||
36 | * @return integer |
||
37 | */ |
||
38 | 3 | public function getLength() |
|
42 | |||
43 | /** |
||
44 | * Generates the nonce. |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | abstract protected function hash(); |
||
49 | |||
50 | /** |
||
51 | * Generates and stores a nonce. |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | 57 | public function generate() |
|
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | 48 | public function getLastNonce() |
|
68 | |||
69 | /** |
||
70 | * Generates and returns a nonce. |
||
71 | * |
||
72 | * @see NoncerAbstract::generate() |
||
73 | */ |
||
74 | 3 | public function __toString() |
|
78 | } |
||
79 |