1 | <?php |
||
17 | class HashHmac |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Hashing Algorithm. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private $algorithm; |
||
26 | |||
27 | /** |
||
28 | * Private Key. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $privateKey; |
||
33 | |||
34 | /** |
||
35 | * Payload Data. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | private $payload = []; |
||
40 | |||
41 | /** |
||
42 | * Date Time Zone. |
||
43 | * |
||
44 | * @var \DateTimeZone |
||
45 | */ |
||
46 | private $timezone; |
||
47 | |||
48 | /** |
||
49 | * @param string $privateKey |
||
50 | * @param string $algo |
||
51 | * @param string $timezone |
||
52 | */ |
||
53 | 13 | public function __construct($privateKey, $algo = 'sha512', $timezone = 'UTC') |
|
59 | |||
60 | /** |
||
61 | * Creates hash from payload. |
||
62 | * @param array $payload |
||
63 | * @return mixed |
||
64 | */ |
||
65 | 4 | public function create($algorithm, array $payload = [], $privateKey) |
|
76 | |||
77 | 2 | public function getEncodedHash(array $payload = []){ |
|
81 | |||
82 | |||
83 | /** |
||
84 | * Compare received hash against payload. |
||
85 | * |
||
86 | * @param $encodedHash |
||
87 | * @param array $payload |
||
88 | * @return bool |
||
89 | * @throws \Exception |
||
90 | */ |
||
91 | 3 | public function compareHash($encodedHash, array $payload = []) |
|
108 | |||
109 | |||
110 | /** |
||
111 | * @param $key |
||
112 | * @return $this |
||
113 | */ |
||
114 | 1 | public function setPrivateKey($key) |
|
120 | |||
121 | /** |
||
122 | * Return current Algorithm |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | 1 | public function getAlgorithm() |
|
130 | |||
131 | |||
132 | public function getPayload(){ |
||
135 | |||
136 | /** |
||
137 | * Returns Current Private Key |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | 2 | public function getPrivateKey() |
|
145 | |||
146 | /** |
||
147 | * @param string $hash |
||
148 | * @param string $payloadHash |
||
149 | * @return bool |
||
150 | * @throws \Exception |
||
151 | */ |
||
152 | 7 | public function verify($hash = '', $payloadHash = '') |
|
164 | |||
165 | 5 | protected function verifyAlgorithm($algo) |
|
175 | } |
||
176 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..